if sck is closed, don't write or read it again, other small fixes
This commit is contained in:
parent
0aff0efb52
commit
63c49195a6
10
xrdp/xrdp.c
10
xrdp/xrdp.c
@ -34,6 +34,8 @@ THREAD_RV THREAD_CC xrdp_listen_run(void* in_val)
|
||||
return 0;
|
||||
}
|
||||
|
||||
//#define CLEAN_CLOSE
|
||||
|
||||
/*****************************************************************************/
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
@ -42,15 +44,23 @@ int main(int argc, char** argv)
|
||||
g_init_system();
|
||||
rv = 0;
|
||||
g_listen = xrdp_listen_create();
|
||||
#ifdef CLEAN_CLOSE
|
||||
if (g_thread_create(xrdp_listen_run, 0) == 0)
|
||||
{
|
||||
g_getchar();
|
||||
g_set_term(1);
|
||||
while (g_listen->status > 0)
|
||||
{
|
||||
g_sleep(100);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = 1;
|
||||
}
|
||||
#else
|
||||
xrdp_listen_main_loop(g_listen);
|
||||
#endif
|
||||
xrdp_listen_delete(g_listen);
|
||||
g_exit_system();
|
||||
return rv;
|
||||
|
@ -139,7 +139,12 @@ int xrdp_listen_main_loop(struct xrdp_listen* self)
|
||||
self->status = 1;
|
||||
self->sck = g_tcp_socket();
|
||||
g_tcp_set_non_blocking(self->sck);
|
||||
g_tcp_bind(self->sck, "3389");
|
||||
if (g_tcp_bind(self->sck, "3389") != 0)
|
||||
{
|
||||
g_printf("bind error in xrdp_listen_main_loop\n\r");
|
||||
g_tcp_close(self->sck);
|
||||
return 1;
|
||||
}
|
||||
error = g_tcp_listen(self->sck);
|
||||
if (error == 0)
|
||||
{
|
||||
|
@ -54,6 +54,11 @@ int xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len)
|
||||
{
|
||||
int rcvd;
|
||||
|
||||
if (self->sck_closed)
|
||||
{
|
||||
DEBUG((" in xrdp_tcp_recv, sck closed\n\r"));
|
||||
return 1;
|
||||
}
|
||||
DEBUG((" in xrdp_tcp_recv, gota get %d bytes\n\r", len));
|
||||
init_stream(s, len);
|
||||
while (len > 0)
|
||||
@ -78,6 +83,7 @@ int xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len)
|
||||
}
|
||||
else if (rcvd == 0)
|
||||
{
|
||||
self->sck_closed = 1;
|
||||
DEBUG((" error = 0 in xrdp_tcp_recv socket %d\n\r", self->sck));
|
||||
return 1;
|
||||
}
|
||||
@ -99,6 +105,11 @@ int xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s)
|
||||
int total;
|
||||
int sent;
|
||||
|
||||
if (self->sck_closed)
|
||||
{
|
||||
DEBUG((" in xrdp_tcp_send, sck closed\n\r"));
|
||||
return 1;
|
||||
}
|
||||
len = s->end - s->data;
|
||||
DEBUG((" in xrdp_tcp_send, gota send %d bytes\n\r", len));
|
||||
total = 0;
|
||||
@ -123,6 +134,7 @@ int xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s)
|
||||
}
|
||||
else if (sent == 0)
|
||||
{
|
||||
self->sck_closed = 1;
|
||||
DEBUG((" error = 0 in xrdp_tcp_send socket %d\n\r", self->sck));
|
||||
return 1;
|
||||
}
|
||||
|
@ -125,6 +125,7 @@ struct xrdp_pen
|
||||
struct xrdp_tcp
|
||||
{
|
||||
int sck;
|
||||
int sck_closed;
|
||||
struct xrdp_iso* iso_layer; /* owner */
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user