MCPcopy Create free account
hub / github.com/F-Stack/f-stack / connSocketBlockingConnect

Function connSocketBlockingConnect

app/redis-6.2.6/src/connection.c:308–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308static 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.

Callers

nothing calls this directly

Calls 2

anetTcpNonBlockConnectFunction · 0.85
aeWaitFunction · 0.85

Tested by

no test coverage detected