summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-02-19 02:12:06 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-02-19 02:12:06 +0000
commit2790a3b0b5ba14985b67e334c7069dcb28e687b6 (patch)
tree9ab38adaa77d36ad347dc37f075c16883f0a061d
parent0123ba3b2664d07318bc018ee091019c26a0a94b (diff)
downloadirssi-2790a3b0b5ba14985b67e334c7069dcb28e687b6.zip
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
-rw-r--r--src/core/net-disconnect.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/core/net-disconnect.c b/src/core/net-disconnect.c
index 3120558f..9f477fb5 100644
--- a/src/core/net-disconnect.c
+++ b/src/core/net-disconnect.c
@@ -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;
-
- /* 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);
- }
+ char buf[512];
+ int count, ret;
+
+ /* 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)