| 306 | } |
| 307 | |
| 308 | static int connSocketBlockingConnect(connection *conn, const char *addr, int port, long long timeout) { |
| 309 | int fd = anetTcpNonBlockConnect(NULL,addr,port); |
| 310 | if (fd == -1) { |
| 311 | conn->state = CONN_STATE_ERROR; |
| 312 | conn->last_errno = errno; |
| 313 | return C_ERR; |
| 314 | } |
| 315 | |
| 316 | if ((aeWait(fd, AE_WRITABLE, timeout) & AE_WRITABLE) == 0) { |
| 317 | conn->state = CONN_STATE_ERROR; |
| 318 | conn->last_errno = ETIMEDOUT; |
| 319 | } |
| 320 | |
| 321 | conn->fd = fd; |
| 322 | conn->state = CONN_STATE_CONNECTED; |
| 323 | return C_OK; |
| 324 | } |
| 325 | |
| 326 | /* Connection-based versions of syncio.c functions. |
| 327 | * NOTE: This should ideally be refactored out in favor of pure async work. |
nothing calls this directly
no test coverage detected