antirez/hiredis — Issue #91: use ae_epoll check async connect error
Author: iamwljiang
Created: 2012-02-27 09:15:39+00:00
State: open

create async connect use redisContextConnectTcp，when non blocking,after use function aeApiPoll in ae_epoll.c
to listen event,but block in epoll_wait when not connected.
so we check and set _EL_ADD_READ in redisAsyncSetConnectCallback
after test,when not connected,will call callback function connectCallback
int redisAsyncSetConnectCallback(redisAsyncContext *ac, redisConnectCallback *fn) {
if (ac->onConnect == NULL) {
ac->onConnect = fn;

/* The common way to detect an established connection is to wait for
* the first write event to be fired. This assumes the related event
* library functions are already set. */
_EL_ADD_WRITE(ac);
_EL_ADD_READ(ac);
return REDIS_OK;
}
return REDIS_ERR;
}

ps:have any question you can contact me,email:iamwljiang@gmail.com