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

Function __redisAsyncFree

deps/hiredis/async.c:301–357  ·  view source on GitHub ↗

Helper function to free the context. */

Source from the content-addressed store, hash-verified

299
300/* Helper function to free the context. */
301static void __redisAsyncFree(redisAsyncContext *ac) {
302 redisContext *c = &(ac->c);
303 redisCallback cb;
304 dictIterator *it;
305 dictEntry *de;
306
307 /* Execute pending callbacks with NULL reply. */
308 while (__redisShiftCallback(&ac->replies,&cb) == REDIS_OK)
309 __redisRunCallback(ac,&cb,NULL);
310
311 /* Execute callbacks for invalid commands */
312 while (__redisShiftCallback(&ac->sub.invalid,&cb) == REDIS_OK)
313 __redisRunCallback(ac,&cb,NULL);
314
315 /* Run subscription callbacks with NULL reply */
316 if (ac->sub.channels) {
317 it = dictGetIterator(ac->sub.channels);
318 if (it != NULL) {
319 while ((de = dictNext(it)) != NULL)
320 __redisRunCallback(ac,dictGetEntryVal(de),NULL);
321 dictReleaseIterator(it);
322 }
323
324 dictRelease(ac->sub.channels);
325 }
326
327 if (ac->sub.patterns) {
328 it = dictGetIterator(ac->sub.patterns);
329 if (it != NULL) {
330 while ((de = dictNext(it)) != NULL)
331 __redisRunCallback(ac,dictGetEntryVal(de),NULL);
332 dictReleaseIterator(it);
333 }
334
335 dictRelease(ac->sub.patterns);
336 }
337
338 /* Signal event lib to clean up */
339 _EL_CLEANUP(ac);
340
341 /* Execute disconnect callback. When redisAsyncFree() initiated destroying
342 * this context, the status will always be REDIS_OK. */
343 if (ac->onDisconnect && (c->flags & REDIS_CONNECTED)) {
344 if (c->flags & REDIS_FREEING) {
345 ac->onDisconnect(ac,REDIS_OK);
346 } else {
347 ac->onDisconnect(ac,(ac->err == 0) ? REDIS_OK : REDIS_ERR);
348 }
349 }
350
351 if (ac->dataCleanup) {
352 ac->dataCleanup(ac->data);
353 }
354
355 /* Cleanup self */
356 redisFree(c);
357}
358

Callers 3

redisAsyncFreeFunction · 0.85
__redisAsyncDisconnectFunction · 0.85
redisProcessCallbacksFunction · 0.85

Calls 7

__redisShiftCallbackFunction · 0.85
__redisRunCallbackFunction · 0.85
redisFreeFunction · 0.85
dictGetIteratorFunction · 0.70
dictNextFunction · 0.70
dictReleaseIteratorFunction · 0.70
dictReleaseFunction · 0.70

Tested by

no test coverage detected