From 080941337d52946231900e0a80dbe49bf525ef5e Mon Sep 17 00:00:00 2001
From: Per Cederqvist <cederp@opera.com>
Date: Thu, 4 Dec 2014 14:37:35 +0100
Subject: [PATCH] Handle read errors in Protocols.LysKOM.Raw.

If there is a network outage, con->read() will return 0 (not the empty
string) after a (long) while.  Treat that properly by calling
connection_lost() in that case as well.

Fixed a backrace in conwrite by returning 0 if the connection
is closed.

(cherry picked from commit 7cdea47d8c28017dbdbff49607c811ca0472000c)
---
 lib/modules/Protocols.pmod/LysKOM.pmod/Raw.pike | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/modules/Protocols.pmod/LysKOM.pmod/Raw.pike b/lib/modules/Protocols.pmod/LysKOM.pmod/Raw.pike
index 03327e1195..ad842bb3e3 100644
--- a/lib/modules/Protocols.pmod/LysKOM.pmod/Raw.pike
+++ b/lib/modules/Protocols.pmod/LysKOM.pmod/Raw.pike
@@ -53,6 +53,7 @@ protected inline int conwrite(string what)
 #ifdef LYSKOM_DEBUG
    werror("-> %O\n",what);
 #endif
+   if (!con) return 0;
    int i=con->write(what)==sizeof(what);
    if (!i) { werror("write failed!!!\n"); _exit(1); }
    return i;
@@ -282,6 +283,7 @@ void read_thread()
       }
       recv(0,s);
    }
+   connection_lost();
 }
 
 #if constant(thread_create) && !LYSKOM_UNTHREADED
-- 
GitLab