]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
rsocket: Succeed setting SO_KEEPALIVE option rsocket
authorSean Hefty <sean.hefty@intel.com>
Mon, 9 Apr 2012 19:05:39 +0000 (12:05 -0700)
committerSean Hefty <sean.hefty@intel.com>
Mon, 16 Apr 2012 18:23:40 +0000 (11:23 -0700)
memcached sets SO_KEEPALIVE, so succeed any requests to set
that option.  We don't actually implement keepalive at this time.

To implement keepalive, we would need to record the last time
that a message was sent or received on an rsocket.  If no
new messages are processed within the keepalive timeout, then
we would need to issue a keepalive message.  For rsockets,
this would simply mean sending a 0-byte control message that
gets ignored on the remote side.

The only real difficulty with handlng keepalive is doing it
without adding threads.  This requires additional work in
poll to occasionally timeout, send keepalive messages, then
return to polling if no new data has arrived.  Alternatively,
we can add a thread to handle sending keepalive messages.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
src/rsocket.c

index 7cfa631661efa8d2cdc0be6ab01e20896480bf22..775e9b07c9b864528a61246551c5f52ea24d195e 100644 (file)
@@ -1661,6 +1661,10 @@ int rsetsockopt(int socket, int level, int optname,
                        opt_on =  !((struct linger *) optval)->l_onoff;
                        ret = 0;
                        break;
+               case SO_KEEPALIVE:
+                       opt_on = *(int *) optval;
+                       ret = 0;
+                       break;
                default:
                        break;
                }
@@ -1701,6 +1705,7 @@ int rgetsockopt(int socket, int level, int optname,
        case SOL_SOCKET:
                switch (optname) {
                case SO_REUSEADDR:
+               case SO_KEEPALIVE:
                        *((int *) optval) = !!(rs->so_opts & (1 << optname));
                        *optlen = sizeof(int);
                        break;