summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsorg71 <jsorg71>2006-12-09 20:53:48 +0000
committerjsorg71 <jsorg71>2006-12-09 20:53:48 +0000
commitf9e6578ed9332c3bb0fab40d703058ad11988b83 (patch)
tree240f3910f4de07af04de1245a3b4d21ebab9cb87
parentea3f8ba0b7f085d23aa6f05f0ca418da6524490b (diff)
downloadxrdp-proprietary-f9e6578ed9332c3bb0fab40d703058ad11988b83.tar.gz
xrdp-proprietary-f9e6578ed9332c3bb0fab40d703058ad11988b83.zip
removed sleep calls from xrdp_tcp
-rw-r--r--common/os_calls.c25
-rw-r--r--common/os_calls.h4
-rw-r--r--libxrdp/xrdp_tcp.c4
3 files changed, 31 insertions, 2 deletions
diff --git a/common/os_calls.c b/common/os_calls.c
index c48fe99e..bd2480e8 100644
--- a/common/os_calls.c
+++ b/common/os_calls.c
@@ -460,6 +460,31 @@ g_tcp_can_send(int sck, int millis)
}
/*****************************************************************************/
+/* wait 'millis' milliseconds for the socket to be able to receive */
+/* returns boolean */
+int
+g_tcp_can_recv(int sck, int millis)
+{
+ fd_set rfds;
+ struct timeval time;
+ int rv;
+
+ time.tv_sec = millis / 1000;
+ time.tv_usec = (millis * 1000) % 1000000;
+ FD_ZERO(&rfds);
+ if (sck > 0)
+ {
+ FD_SET(((unsigned int)sck), &rfds);
+ rv = select(sck + 1, &rfds, 0, 0, &time);
+ if (rv > 0)
+ {
+ return 1;
+ }
+ }
+ return 0;
+}
+
+/*****************************************************************************/
int
g_tcp_select(int sck1, int sck2)
{
diff --git a/common/os_calls.h b/common/os_calls.h
index a833569a..caabd1e8 100644
--- a/common/os_calls.h
+++ b/common/os_calls.h
@@ -76,6 +76,10 @@ g_tcp_send(int sck, const void* ptr, int len, int flags);
int
g_tcp_last_error_would_block(int sck);
int
+g_tcp_can_send(int sck, int millis);
+int
+g_tcp_can_recv(int sck, int millis);
+int
g_tcp_select(int sck1, int sck2);
void
g_sleep(int msecs);
diff --git a/libxrdp/xrdp_tcp.c b/libxrdp/xrdp_tcp.c
index c3629a46..1d1effc2 100644
--- a/libxrdp/xrdp_tcp.c
+++ b/libxrdp/xrdp_tcp.c
@@ -72,7 +72,7 @@ xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len)
{
if (g_tcp_last_error_would_block(self->sck))
{
- g_sleep(1);
+ g_tcp_can_recv(self->sck, 10);
}
else
{
@@ -121,7 +121,7 @@ xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s)
{
if (g_tcp_last_error_would_block(self->sck))
{
- g_sleep(1);
+ g_tcp_can_send(self->sck, 10);
}
else
{