[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [dev-serveez] Small patch (bugfixes)
From: |
Andreas Rottmann |
Subject: |
Re: [dev-serveez] Small patch (bugfixes) |
Date: |
22 Dec 2002 21:16:41 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
Andreas Rottmann <address@hidden> writes:
> stefan <address@hidden> writes:
>
> > On 19 Dec 2002, Andreas Rottmann wrote:
>
> I have attached a patch with my current modifications of
> svz_check_sockets_poll() - this should make my intention clear. One
> could discuss if this should be default behavior, but IMO its a
> reasonable solution that avoids receive buffer overflows completly.
>
Well, here actually is the patch.
<cvs-diff>
Index: server-loop.c
===================================================================
RCS file: /cvsroot/serveez/serveez/src/libserveez/server-loop.c,v
retrieving revision 1.9
diff -u -p -u -r1.9 server-loop.c
--- server-loop.c 9 Jun 2002 10:13:09 -0000 1.9
+++ server-loop.c 22 Dec 2002 16:04:07 -0000
@@ -85,6 +85,10 @@
svz_sock_schedule_for_shutdown (sock); \
} while (0)
+#define SOCK_READ_SELECTABLE(sock) \
+ ((sock)->recv_buffer_fill < (sock)->recv_buffer_size \
+ || (sock)->recv_buffer_size == 0)
+
#ifndef __MINGW32__
/*
@@ -149,9 +153,10 @@ svz_check_sockets_select (void)
if (sock->flags & SOCK_FLAG_RECV_PIPE)
{
FD_SET (sock->pipe_desc[READ], &except_fds);
- FD_SET (sock->pipe_desc[READ], &read_fds);
- if (sock->pipe_desc[READ] > nfds)
- nfds = sock->pipe_desc[READ];
+ if (sock->recv_buffer_fill < sock->recv_buffer_size)
+ FD_SET (sock->pipe_desc[READ], &read_fds);
+ if (sock->pipe_desc[READ] > nfds)
+ nfds = sock->pipe_desc[READ];
}
}
@@ -171,7 +176,8 @@ svz_check_sockets_select (void)
nfds = sock->sock_desc;
/* Put socket into READ if necessary. */
- if (!(sock->flags & SOCK_FLAG_CONNECTING))
+ if (!(sock->flags & SOCK_FLAG_CONNECTING)
+ && sock->recv_buffer_fill < sock->recv_buffer_size)
{
FD_SET (sock->sock_desc, &read_fds);
}
@@ -430,7 +436,7 @@ svz_check_sockets_poll (void)
svz_sock_schedule_for_shutdown (sock);
continue;
}
-
+
/* send pipe ? */
if (sock->flags & SOCK_FLAG_SEND_PIPE)
{
@@ -445,10 +451,13 @@ svz_check_sockets_poll (void)
/* receive pipe ? */
if (sock->flags & SOCK_FLAG_RECV_PIPE)
{
- fd = sock->pipe_desc[READ];
- FD_POLL_IN (fd, sock);
- nfds++;
- }
+ if (sock->recv_buffer_fill < sock->recv_buffer_size)
+ {
+ fd = sock->pipe_desc[READ];
+ FD_POLL_IN (fd, sock);
+ nfds++;
+ }
+ }
}
/* normal bi-directional socket connection */
@@ -463,16 +472,19 @@ svz_check_sockets_poll (void)
/* poll this socket for reading and writing */
fd = sock->sock_desc;
- if (!(sock->flags & SOCK_FLAG_CONNECTING))
- {
- FD_POLL_IN (fd, sock);
+ if (!(sock->flags & SOCK_FLAG_CONNECTING)
+ && ((sock->flags & SOCK_FLAG_LISTENING)
+ || sock->recv_buffer_fill < sock->recv_buffer_size))
+ {
+ FD_POLL_IN (fd, sock);
+ nfds++;
}
if (!sock->unavailable && (sock->send_buffer_fill > 0 ||
sock->flags & SOCK_FLAG_CONNECTING))
{
FD_POLL_OUT (fd, sock);
+ nfds++;
}
- nfds++;
}
}
@@ -652,7 +664,8 @@ svz_check_sockets_MinGW (void)
*/
if (sock->flags & SOCK_FLAG_RECV_PIPE)
{
- if (sock->read_socket)
+ if (sock->read_socket
+ && sock->recv_buffer_fill < sock->recv_buffer_size)
if (sock->read_socket (sock))
svz_sock_schedule_for_shutdown (sock);
}
@@ -673,7 +686,8 @@ svz_check_sockets_MinGW (void)
nfds = sock->sock_desc;
/* Put a client's socket into READ if necessary. */
- if (!(sock->flags & SOCK_FLAG_CONNECTING))
+ if (!(sock->flags & SOCK_FLAG_CONNECTING)
+ && sock->recv_buffer_fill < sock->recv_buffer_size)
{
FD_SET (sock->sock_desc, &read_fds);
}
</cvs-diff>
Regards, Andy
--
Andreas Rottmann | address@hidden | address@hidden |
address@hidden
http://www.8ung.at/rotty | GnuPG Key: http://www.8ung.at/rotty/gpg.asc
Fingerprint | DFB4 4EB4 78A4 5EEE 6219 F228 F92F CFC5 01FD 5B62