added g_close_wait_obj and size parameter to g_write_ip_address

master
Jay Sorg 13 years ago
parent d08e27e824
commit bde5dd6671

@ -562,31 +562,33 @@ g_tcp_accept(int sck)
/*****************************************************************************/
void APP_CC
g_write_ip_address(int rcv_sck, char* ip_address)
g_write_ip_address(int rcv_sck, char* ip_address, int bytes)
{
struct sockaddr_in s;
struct in_addr in;
int len;
int ip_port;
int ok;
memset(&s,0,sizeof(&s));
ok = 0;
memset(&s, 0, sizeof(s));
len = sizeof(s);
getpeername(rcv_sck,(struct sockaddr*)&s, &len);
memset(&in,0,sizeof(in));
in.s_addr = s.sin_addr.s_addr;
ip_port = ntohs(s.sin_port);
if (ip_port != 0)
if (getpeername(rcv_sck,(struct sockaddr*)&s, &len) == 0)
{
sprintf(ip_address, "%s:%d - socket: %d", inet_ntoa(in), ip_port, rcv_sck);
memset(&in, 0, sizeof(in));
in.s_addr = s.sin_addr.s_addr;
ip_port = ntohs(s.sin_port);
if (ip_port != 0)
{
ok = 1;
snprintf(ip_address, bytes, "%s:%d - socket: %d", inet_ntoa(in),
ip_port, rcv_sck);
}
}
else
if (!ok)
{
sprintf(ip_address, "NULL:NULL - socket: %d", rcv_sck);
snprintf(ip_address, bytes, "NULL:NULL - socket: %d", rcv_sck);
}
}
/*****************************************************************************/
@ -995,6 +997,19 @@ g_delete_wait_obj(tbus obj)
#endif
}
/*****************************************************************************/
/* returns error */
/* close but do not delete the wait obj, used after fork */
int APP_CC
g_close_wait_obj(tbus obj)
{
#ifdef _WIN32
#else
close((int)obj);
#endif
return 0;
}
/*****************************************************************************/
/* returns error */
int APP_CC

@ -104,7 +104,7 @@ g_tcp_can_recv(int sck, int millis);
int APP_CC
g_tcp_select(int sck1, int sck2);
void APP_CC
g_write_ip_address(int rcv_sck, char* ip_address);
g_write_ip_address(int rcv_sck, char* ip_address, int bytes);
void APP_CC
g_sleep(int msecs);
tbus APP_CC
@ -122,6 +122,8 @@ g_is_wait_obj_set(tbus obj);
int APP_CC
g_delete_wait_obj(tbus obj);
int APP_CC
g_close_wait_obj(tbus obj);
int APP_CC
g_obj_wait(tbus* read_objs, int rcount, tbus* write_objs, int wcount,
int mstimeout);
void APP_CC

@ -136,6 +136,7 @@ struct xrdp_rdp* APP_CC
xrdp_rdp_create(struct xrdp_session* session, struct trans* trans)
{
struct xrdp_rdp* self = (struct xrdp_rdp *)NULL;
int bytes;
DEBUG(("in xrdp_rdp_create"));
self = (struct xrdp_rdp*)g_malloc(sizeof(struct xrdp_rdp), 1);
@ -153,7 +154,9 @@ xrdp_rdp_create(struct xrdp_session* session, struct trans* trans)
self->client_info.cache2_size = 1024;
self->client_info.cache3_entries = 262;
self->client_info.cache3_size = 4096;
g_write_ip_address(trans->sck, self->client_info.client_ip); /* load client ip info */
/* load client ip info */
bytes = sizeof(self->client_info.client_ip) - 1;
g_write_ip_address(trans->sck, self->client_info.client_ip, bytes);
#if defined(XRDP_FREERDP1)
self->mppc_enc = mppc_enc_new(PROTO_RDP_50);
#endif

@ -111,8 +111,8 @@ xrdp_child_fork(void)
char text[256];
/* close, don't delete these */
g_tcp_close((int)g_term_event);
g_tcp_close((int)g_sync_event);
g_close_wait_obj(g_term_event);
g_close_wait_obj(g_sync_event);
pid = g_getpid();
g_snprintf(text, 255, "xrdp_%8.8x_main_term", pid);
g_term_event = g_create_wait_obj(text);

@ -204,7 +204,7 @@ xrdp_listen_fork(struct xrdp_listen* self, struct trans* server_trans)
xrdp_child_fork();
/* recreate the process done wait object, not used in fork mode */
/* close, don't delete this */
g_tcp_close((int)(self->pro_done_event));
g_close_wait_obj(self->pro_done_event);
xrdp_listen_create_pro_done(self);
/* delete listener, child need not listen */
trans_delete(self->listen_trans);

Loading…
Cancel
Save