rsockets: Fix setting flags in rfctl
authorSean Hefty <sean.hefty@intel.com>
Fri, 6 Feb 2015 05:17:03 +0000 (21:17 -0800)
committerSean Hefty <sean.hefty@intel.com>
Fri, 6 Feb 2015 05:17:03 +0000 (21:17 -0800)
The rfcntl() call to set rsocket flags merely OR's in
the updated flags with the existing ones, rather than
replacing them.  Also, it does not handle setting an
rsocket from nonblocking mode back to blocking mode.

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

index 4ff3a42..6e8f375 100644 (file)
@@ -3696,11 +3696,11 @@ int rfcntl(int socket, int cmd, ... /* arg */ )
                break;
        case F_SETFL:
                param = va_arg(args, long);
-               if (param & O_NONBLOCK)
-                       ret = rs_set_nonblocking(rs, O_NONBLOCK);
+               if ((rs->fd_flags & O_NONBLOCK) != (param & O_NONBLOCK))
+                       ret = rs_set_nonblocking(rs, param & O_NONBLOCK);
 
                if (!ret)
-                       rs->fd_flags |= param;
+                       rs->fd_flags = param;
                break;
        default:
                ret = ERR(ENOTSUP);