MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / __redisAsyncHandleConnect

Function __redisAsyncHandleConnect

deps/hiredis/async.c:602–625  ·  view source on GitHub ↗

Internal helper function to detect socket status the first time a read or * write event fires. When connecting was not successful, the connect callback * is called with a REDIS_ERR status and the context is free'd. */

Source from the content-addressed store, hash-verified

600 * write event fires. When connecting was not successful, the connect callback
601 * is called with a REDIS_ERR status and the context is free'd. */
602static int __redisAsyncHandleConnect(redisAsyncContext *ac) {
603 int completed = 0;
604 redisContext *c = &(ac->c);
605
606 if (redisCheckConnectDone(c, &completed) == REDIS_ERR) {
607 /* Error! */
608 redisCheckSocketError(c);
609 __redisAsyncHandleConnectFailure(ac);
610 return REDIS_ERR;
611 } else if (completed == 1) {
612 /* connected! */
613 if (c->connection_type == REDIS_CONN_TCP &&
614 redisSetTcpNoDelay(c) == REDIS_ERR) {
615 __redisAsyncHandleConnectFailure(ac);
616 return REDIS_ERR;
617 }
618
619 if (ac->onConnect) ac->onConnect(ac, REDIS_OK);
620 c->flags |= REDIS_CONNECTED;
621 return REDIS_OK;
622 } else {
623 return REDIS_OK;
624 }
625}
626
627void redisAsyncRead(redisAsyncContext *ac) {
628 redisContext *c = &(ac->c);

Callers 2

redisAsyncHandleReadFunction · 0.85
redisAsyncHandleWriteFunction · 0.85

Calls 4

redisCheckConnectDoneFunction · 0.85
redisCheckSocketErrorFunction · 0.85
redisSetTcpNoDelayFunction · 0.85

Tested by

no test coverage detected