| 163 | } |
| 164 | |
| 165 | redisAsyncContext *redisAsyncConnectWithOptions(const redisOptions *options) { |
| 166 | redisOptions myOptions = *options; |
| 167 | redisContext *c; |
| 168 | redisAsyncContext *ac; |
| 169 | |
| 170 | /* Clear any erroneously set sync callback and flag that we don't want to |
| 171 | * use freeReplyObject by default. */ |
| 172 | myOptions.push_cb = NULL; |
| 173 | myOptions.options |= REDIS_OPT_NO_PUSH_AUTOFREE; |
| 174 | |
| 175 | myOptions.options |= REDIS_OPT_NONBLOCK; |
| 176 | c = redisConnectWithOptions(&myOptions); |
| 177 | if (c == NULL) { |
| 178 | return NULL; |
| 179 | } |
| 180 | |
| 181 | ac = redisAsyncInitialize(c); |
| 182 | if (ac == NULL) { |
| 183 | redisFree(c); |
| 184 | return NULL; |
| 185 | } |
| 186 | |
| 187 | /* Set any configured async push handler */ |
| 188 | redisAsyncSetPushCallback(ac, myOptions.async_push_cb); |
| 189 | |
| 190 | __redisAsyncCopyError(ac); |
| 191 | return ac; |
| 192 | } |
| 193 | |
| 194 | redisAsyncContext *redisAsyncConnect(const char *ip, int port) { |
| 195 | redisOptions options = {0}; |