diff options
author | Jay Sorg <jay.sorg@gmail.com> | 2012-05-26 17:24:04 -0700 |
---|---|---|
committer | Jay Sorg <jay.sorg@gmail.com> | 2012-05-26 17:24:04 -0700 |
commit | bde5dd66713cec177846627bf026d8bcddbb41a8 (patch) | |
tree | 3b914749067f0b70a792a2e48ceda737c2f2db34 /common/os_calls.c | |
parent | d08e27e82463c0f998c82ff62cd6dda81822c68b (diff) | |
download | xrdp-proprietary-bde5dd66713cec177846627bf026d8bcddbb41a8.tar.gz xrdp-proprietary-bde5dd66713cec177846627bf026d8bcddbb41a8.zip |
added g_close_wait_obj and size parameter to g_write_ip_address
Diffstat (limited to 'common/os_calls.c')
-rw-r--r-- | common/os_calls.c | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/common/os_calls.c b/common/os_calls.c index 466cdbdf..65c6808a 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -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); } - } /*****************************************************************************/ @@ -997,6 +999,19 @@ g_delete_wait_obj(tbus obj) /*****************************************************************************/ /* 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 g_obj_wait(tbus* read_objs, int rcount, tbus* write_objs, int wcount, int mstimeout) |