Patch: call cleanup() when ::recv return error
From: Roelof Naude <roelof.naude@xxxxxxxxxx>
Date: Thu, 22 Feb 2007 11:17:03 +0100 (CET)
hi

i had the scenario where a client was connected to multiple chatrooms.
on disconnect from server, i would like to re-connect (and re-join
chatrooms). to cleanup the chatrooms, one have to leave the room (done
automatic by mucroom destructor). the 'leave' operation involve sending
a presence update, but the socket is not valid anymore, resulting in
SIGPIPE. unfortunately the default behavior of SIGPIPE is to abort the
app....

the attach patch will call connection::cleanup when ::recv returns <= 0.
ignoring SIGPIPE could've worked as well i guess.

regards
roelof.
--- connection.cpp.orig 2007-02-22 10:26:43.460873472 +0200
+++ connection.cpp      2007-02-22 10:35:10.242830904 +0200
@@ -1094,11 +1094,13 @@
     if( size < 0 )
     {
       // error
+      cleanup();
       return ConnIoError;
     }
     else if( size == 0 )
     {
       // connection closed
+      cleanup();
       return ConnUserDisconnected;
     }