check if server is shutting down

ulab-original
jsorg71 18 years ago
parent 728550e1b4
commit 08e292faf4

@ -74,11 +74,20 @@ libxrdp_process_data(struct xrdp_session* session)
int cont; int cont;
int rv; int rv;
int code; int code;
int term;
term = 0;
cont = 1; cont = 1;
rv = 0; rv = 0;
while ((cont || !session->up_and_running) && !session->term) while ((cont || !session->up_and_running) && !term)
{ {
if (session->is_term != 0)
{
if (session->is_term())
{
term = 1;
}
}
code = 0; code = 0;
if (xrdp_rdp_recv((struct xrdp_rdp*)session->rdp, session->s, &code) != 0) if (xrdp_rdp_recv((struct xrdp_rdp*)session->rdp, session->s, &code) != 0)
{ {
@ -104,7 +113,7 @@ libxrdp_process_data(struct xrdp_session* session)
{ {
DEBUG(("libxrdp_process_data returned non zero")); DEBUG(("libxrdp_process_data returned non zero"));
cont = 0; cont = 0;
session->term = 1; term = 1;
} }
break; break;
default: default:

@ -98,7 +98,6 @@ struct xrdp_session
{ {
long id; long id;
int sck; int sck;
int term; /* do we need this */
int (*callback)(long id, int msg, long param1, long param2, long param3, int (*callback)(long id, int msg, long param1, long param2, long param3,
long param4); long param4);
void* rdp; void* rdp;
@ -106,6 +105,7 @@ struct xrdp_session
struct xrdp_client_info* client_info; struct xrdp_client_info* client_info;
int up_and_running; int up_and_running;
struct stream* s; struct stream* s;
int (*is_term)(void);
}; };
struct xrdp_session* DEFAULT_CC struct xrdp_session* DEFAULT_CC

@ -57,6 +57,7 @@ int APP_CC
xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len) xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len)
{ {
int rcvd; int rcvd;
struct xrdp_session* session;
if (self->sck_closed) if (self->sck_closed)
{ {
@ -64,6 +65,7 @@ xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len)
return 1; return 1;
} }
DEBUG((" in xrdp_tcp_recv, gota get %d bytes", len)); DEBUG((" in xrdp_tcp_recv, gota get %d bytes", len));
session = self->iso_layer->mcs_layer->sec_layer->rdp_layer->session;
init_stream(s, len); init_stream(s, len);
while (len > 0) while (len > 0)
{ {
@ -72,7 +74,17 @@ xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len)
{ {
if (g_tcp_last_error_would_block(self->sck)) if (g_tcp_last_error_would_block(self->sck))
{ {
g_tcp_can_recv(self->sck, 10); if (!g_tcp_can_recv(self->sck, 10))
{
if (session->is_term != 0)
{
if (session->is_term())
{
DEBUG((" out xrdp_tcp_recv, terminated"));
return 1;
}
}
}
} }
else else
{ {
@ -105,6 +117,7 @@ xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s)
int len; int len;
int total; int total;
int sent; int sent;
struct xrdp_session* session;
if (self->sck_closed) if (self->sck_closed)
{ {
@ -113,6 +126,7 @@ xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s)
} }
len = s->end - s->data; len = s->end - s->data;
DEBUG((" in xrdp_tcp_send, gota send %d bytes", len)); DEBUG((" in xrdp_tcp_send, gota send %d bytes", len));
session = self->iso_layer->mcs_layer->sec_layer->rdp_layer->session;
total = 0; total = 0;
while (total < len) while (total < len)
{ {
@ -121,7 +135,17 @@ xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s)
{ {
if (g_tcp_last_error_would_block(self->sck)) if (g_tcp_last_error_would_block(self->sck))
{ {
g_tcp_can_send(self->sck, 10); if (!g_tcp_can_send(self->sck, 10))
{
if (session->is_term != 0)
{
if (session->is_term())
{
DEBUG((" out xrdp_tcp_send, terminated"));
return 1;
}
}
}
} }
else else
{ {

Loading…
Cancel
Save