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. */
| 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. */ |
| 602 | static 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 | |
| 627 | void redisAsyncRead(redisAsyncContext *ac) { |
| 628 | redisContext *c = &(ac->c); |
no test coverage detected