Properly handle EINPROGRESS error from connect() 13/205913/1
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 10 May 2019 08:39:20 +0000 (10:39 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 10 May 2019 08:47:11 +0000 (10:47 +0200)
If connect() fails with EINPROGRESS, the connection may be completed
by polling/selecting the socket for writing. This commit replaces
POLLIN with POLLOUT to handle it properly.

Change-Id: If332634c6d517d7ec00f19a5970e7fe16ee9bb06

src/common/connection.cpp

index 65787c8363fab3d0df88ae9bc2e0e5776d4a9513..ab231dd4d246122dbd86dfc747ccfbafab6be534 100644 (file)
@@ -114,7 +114,7 @@ public:
 
         int retval = TEMP_FAILURE_RETRY(connect(m_sock, (struct sockaddr*)&clientAddr, SUN_LEN(&clientAddr)));
         if ((retval == -1) && (errno == EINPROGRESS)) {
-            if (0 >= waitForSocket(m_sock, POLLIN, POLL_TIMEOUT)) {
+            if (0 >= waitForSocket(m_sock, POLLOUT, POLL_TIMEOUT)) {
                 LogError("Error in waitForSocket.");
                 return SECURITY_MANAGER_ERROR_SOCKET;
             }