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:
parent
0123ba3b26
commit
2790a3b0b5
@ -47,16 +47,20 @@ static void net_disconnect_remove(NET_DISCONNECT_REC *rec)
|
||||
|
||||
static void sig_disconnect(NET_DISCONNECT_REC *rec)
|
||||
{
|
||||
char buf[128];
|
||||
int ret;
|
||||
char buf[512];
|
||||
int count, ret;
|
||||
|
||||
/* check if there's any data waiting in socket */
|
||||
while ((ret = net_receive(rec->handle, buf, sizeof(buf))) > 0) ;
|
||||
|
||||
if (ret == -1) {
|
||||
/* socket was closed */
|
||||
net_disconnect_remove(rec);
|
||||
}
|
||||
/* 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) {
|
||||
/* socket was closed */
|
||||
net_disconnect_remove(rec);
|
||||
}
|
||||
count++;
|
||||
} while (ret == sizeof(buf) && count < 10);
|
||||
}
|
||||
|
||||
static int sig_timeout_disconnect(void)
|
||||
|
Loading…
Reference in New Issue
Block a user