1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

When reading data from socket, read max. 5kB at a time so we won't get

stuck if socket just keeps sending more and more data.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1243 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-02-19 02:12:06 +00:00 committed by cras
parent 0123ba3b26
commit 2790a3b0b5

View File

@ -47,16 +47,20 @@ static void net_disconnect_remove(NET_DISCONNECT_REC *rec)
static void sig_disconnect(NET_DISCONNECT_REC *rec) static void sig_disconnect(NET_DISCONNECT_REC *rec)
{ {
char buf[128]; char buf[512];
int ret; int count, ret;
/* check if there's any data waiting in socket */
while ((ret = net_receive(rec->handle, buf, sizeof(buf))) > 0) ;
/* check if there's any data waiting in socket. read max. 5kB so
if server just keeps sending us stuff we won't get stuck */
count = 0;
do {
ret = net_receive(rec->handle, buf, sizeof(buf));
if (ret == -1) { if (ret == -1) {
/* socket was closed */ /* socket was closed */
net_disconnect_remove(rec); net_disconnect_remove(rec);
} }
count++;
} while (ret == sizeof(buf) && count < 10);
} }
static int sig_timeout_disconnect(void) static int sig_timeout_disconnect(void)