Added check if socket is connected to prevent sending disconnect
sequence to a closed socket. git-svn-id: svn://svn.code.sf.net/p/rdesktop/code/rdesktop/trunk@1681 423420c4-83ab-492f-b58f-81f9feb106b5
This commit is contained in:
parent
91d026f52c
commit
9f174ea864
1
proto.h
1
proto.h
@ -207,6 +207,7 @@ STREAM tcp_recv(STREAM s, uint32 length);
|
|||||||
RD_BOOL tcp_connect(char *server);
|
RD_BOOL tcp_connect(char *server);
|
||||||
void tcp_disconnect(void);
|
void tcp_disconnect(void);
|
||||||
char *tcp_get_address(void);
|
char *tcp_get_address(void);
|
||||||
|
RD_BOOL tcp_is_connected(void);
|
||||||
void tcp_reset_state(void);
|
void tcp_reset_state(void);
|
||||||
RD_BOOL tcp_tls_connect(void);
|
RD_BOOL tcp_tls_connect(void);
|
||||||
RD_BOOL tcp_tls_get_server_pubkey(STREAM s);
|
RD_BOOL tcp_tls_get_server_pubkey(STREAM s);
|
||||||
|
@ -1023,7 +1023,8 @@ main(int argc, char *argv[])
|
|||||||
rdp_main_loop(&deactivated, &ext_disc_reason);
|
rdp_main_loop(&deactivated, &ext_disc_reason);
|
||||||
|
|
||||||
DEBUG(("Disconnecting...\n"));
|
DEBUG(("Disconnecting...\n"));
|
||||||
rdp_disconnect();
|
if (!tcp_is_connected())
|
||||||
|
rdp_disconnect();
|
||||||
|
|
||||||
if (g_redirect)
|
if (g_redirect)
|
||||||
continue;
|
continue;
|
||||||
|
10
tcp.c
10
tcp.c
@ -515,6 +515,16 @@ tcp_get_address()
|
|||||||
return ipaddr;
|
return ipaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RD_BOOL
|
||||||
|
tcp_is_connected()
|
||||||
|
{
|
||||||
|
struct sockaddr_in sockaddr;
|
||||||
|
socklen_t len = sizeof(sockaddr);
|
||||||
|
if (getpeername(g_sock, (struct sockaddr *) &sockaddr, &len))
|
||||||
|
return True;
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
/* reset the state of the tcp layer */
|
/* reset the state of the tcp layer */
|
||||||
/* Support for Session Directory */
|
/* Support for Session Directory */
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user