add KEEPALIVE to TCP connections
authorminima <minima>
Thu, 10 Jan 2002 23:46:17 +0000 (23:46 +0000)
committerminima <minima>
Thu, 10 Jan 2002 23:46:17 +0000 (23:46 +0000)
Changes
perl/Msg.pm
src/client.c

diff --git a/Changes b/Changes
index ed992bdc614b496a1702f0e43cadc118f36e4aef..82d90bb4d09a20bed31707a12e77fb95955807f5 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,7 +1,10 @@
 10Jan02=======================================================================
 1. set SO_LINGER = 0 to try to prevent the system sending data on a closing
-socket. This MAY help some of the hanging problems.
+socket. This MAY help some of the hanging problems (but I am now beginning
+to doubt this).
 2. do the same on the C client (which means DON'T FORGET to make it).
+3. set KEEPALIVE on TCP connections for both the node and C Client (you will
+have to make the C client again) and you will need to restart.
 08Jan02=======================================================================
 1. altered sh/qrz to point to the new server
 2. alter the character set handling a bit to make it better for spanish
index 746878e26e3c0df1288781e5420b35a1fec18be6..f2881c8ff9a947932c926bb1c4f5a0cf9e57fac1 100644 (file)
@@ -364,7 +364,8 @@ sub nolinger
                my ($l, $t) = unpack("ll", $buf);
                dbg("Linger is: $buf = $l $t");
        }
-       setsockopt($conn->{sock}, SOL_SOCKET, SO_LINGER, pack("ll", 0, 0)) or confess "setsockopt: $!";
+       setsockopt($conn->{sock}, SOL_SOCKET, SO_LINGER, pack("ll", 0, 0)) or confess "setsockopt linger: $!";
+       setsockopt($conn->{sock}, SOL_SOCKET, SO_KEEPALIVE, 1) or confess "setsockopt keepalive: $!";
        if (isdbg('sock') && ($buf = getsockopt($conn->{sock}, SOL_SOCKET, SO_LINGER))) {
                my ($l, $t) = unpack("ll", $buf);
                dbg("Linger is: $buf = $l $t");
index 049d64f6a2fd9d833365b8d6340f3d2ac54cbace..69a8aaebd099eb180452eb601098a2d55462645c 100644 (file)
@@ -825,6 +825,7 @@ void connect_to_node()
        struct hostent *hp, *gethostbyname();
        struct sockaddr_in server;
        int nodef;
+       int one = 1;
        sel_t *sp;
        struct linger lg;
                                        
@@ -848,6 +849,9 @@ void connect_to_node()
        if (setsockopt(nodef, SOL_SOCKET, SO_LINGER, &lg, sizeof lg) < 0) {
                die("Error on SO_LINGER to %s port %d (%d)", node_addr, node_port, errno);
        }
+       if (setsockopt(nodef, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof one) < 0) {
+               die("Error on SO_KEEPALIVE to %s port %d (%d)", node_addr, node_port, errno);
+       }
        
        node = fcb_new(nodef, MSG);
        node->sp = sel_open(nodef, node, "Msg System", fcb_handler, MSG, SEL_INPUT);