]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
enable TCP keepalives
authorAndrew Tridgell <tridge@samba.org>
Tue, 15 May 2007 08:40:56 +0000 (18:40 +1000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 15 May 2007 08:40:56 +0000 (18:40 +1000)
(This used to be ctdb commit a44f760f6260359201d8431d2f1267af2bc6b1b1)

ctdb/tcp/tcp_connect.c

index 2ae41f31bd1451142fb3c8d5043d9b9875f7f8c2..8a2f70c7b1f4d9385e0c125f796e395e9dce5178 100644 (file)
@@ -82,6 +82,7 @@ static void ctdb_node_connect_write(struct event_context *ev, struct fd_event *f
        talloc_free(fde);
        
         setsockopt(tnode->fd,IPPROTO_TCP,TCP_NODELAY,(char *)&one,sizeof(one));
+        setsockopt(tnode->fd,SOL_SOCKET,SO_KEEPALIVE,(char *)&one,sizeof(one));
 
        ctdb_queue_set_fd(tnode->queue, tnode->fd);
 
@@ -180,6 +181,7 @@ static void ctdb_listen_event(struct event_context *ev, struct fd_event *fde,
        socklen_t len;
        int fd;
        struct ctdb_incoming *in;
+       int one = 1;
 
        ctdb = talloc_get_type(private_data, struct ctdb_context);
        ctcp = talloc_get_type(ctdb->private_data, struct ctdb_tcp);
@@ -194,6 +196,8 @@ static void ctdb_listen_event(struct event_context *ev, struct fd_event *fde,
 
        set_nonblocking(in->fd);
 
+        setsockopt(in->fd,SOL_SOCKET,SO_KEEPALIVE,(char *)&one,sizeof(one));
+
        in->queue = ctdb_queue_setup(ctdb, in, in->fd, CTDB_TCP_ALIGNMENT, 
                                     ctdb_tcp_read_cb, in);
 }