rsocket; Set POLLERR bit in revent in case of rs_connect_error
authorSasha Kotchubievsky <sashakot@mellanox.com>
Wed, 25 Mar 2015 22:27:01 +0000 (15:27 -0700)
committerSean Hefty <sean.hefty@intel.com>
Thu, 26 Mar 2015 19:38:06 +0000 (12:38 -0700)
In non-blocking mode, on server side accept returns a new data
socket and select/poll should indicate when the socket is ready
for reading/writing.

This fix allows an application to receive an error in case of
connection failure.

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
src/rsocket.c

index 1055728..bcb253e 100644 (file)
@@ -2964,19 +2964,22 @@ check_cq:
 
        if (rs->state & rs_opening) {
                ret = rs_do_connect(rs);
-               if (ret) {
-                       if (errno == EINPROGRESS) {
-                               errno = 0;
-                               return 0;
-                       } else {
-                               return POLLOUT;
-                       }
+               if (ret && (errno == EINPROGRESS)) {
+                       errno = 0;
+               } else {
+                       goto check_cq;
                }
-               goto check_cq;
        }
 
-       if (rs->state == rs_connect_error)
-               return (rs->err && events & POLLOUT) ? POLLOUT : 0;
+       if (rs->state == rs_connect_error) {
+               revents = 0;
+               if (events & POLLOUT)
+                       revents |= POLLOUT;
+               if (events & POLLIN)
+                       revents |= POLLIN;
+               revents |= POLLERR;
+               return revents;
+       }
 
        return 0;
 }