Fix bug #3139, "Mainwindow unresponsive due to a busy loop"
authorColin Leroy <colin@colino.net>
Mon, 21 Apr 2014 11:49:46 +0000 (13:49 +0200)
committerColin Leroy <colin@colino.net>
Mon, 21 Apr 2014 11:49:46 +0000 (13:49 +0200)
In case of unexpected return from gnutls_record_recv(), set errno to
a fatal error.

src/common/session.c
src/common/socket.c

index c43e5e413e92e40873c16b12b015d5c8bf875ddc..25038c98fb1d3916e492fb0f9b2044130442ce33 100644 (file)
@@ -528,9 +528,10 @@ static gboolean session_read_msg_cb(SockInfo *source, GIOCondition condition,
        session_set_timeout(session, session->timeout_interval);
 
        if (session->read_buf_len == 0) {
-               gint read_len;
+               gint read_len = -1;
 
-               read_len = sock_read(session->sock, session->read_buf,
+               if (session->sock)
+                       read_len = sock_read(session->sock, session->read_buf,
                                     SESSION_BUFFSIZE - 1);
 
                if (read_len == -1 && session->state == SESSION_DISCONNECTED) {
index 0245910cf17ac1c8d9220464c449df6e12161672..1d6638d07afe6882493786a3e9a1b2c0c40c4947 100644 (file)
@@ -1417,6 +1417,8 @@ static gint ssl_read(gnutls_session_t ssl, gchar *buf, gint len)
                        return -1;
 
                default:
+                       debug_print("Unexpected SSL read result %d\n", r);
+                       errno = EIO;
                        return -1;
                }
        }