From 960d584eff6ed929951b87e7e235e378be3c1026 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Mon, 9 Apr 2012 12:05:39 -0700 Subject: [PATCH] rsocket: Succeed setting SO_KEEPALIVE option 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 --- src/rsocket.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rsocket.c b/src/rsocket.c index 7cfa6316..775e9b07 100644 --- a/src/rsocket.c +++ b/src/rsocket.c @@ -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; -- 2.46.0