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

Function aeResizeSetSize

src/ae.cpp:384–401  ·  view source on GitHub ↗

Resize the maximum set size of the event loop. * If the requested set size is smaller than the current set size, but * there is already a file descriptor in use that is >= the requested * set size minus one, AE_ERR is returned and the operation is not * performed at all. * * Otherwise AE_OK is returned and the operation is successful. */

Source from the content-addressed store, hash-verified

382 *
383 * Otherwise AE_OK is returned and the operation is successful. */
384int aeResizeSetSize(aeEventLoop *eventLoop, int setsize) {
385 serverAssert(g_eventLoopThisThread == NULL || g_eventLoopThisThread == eventLoop);
386 int i;
387
388 if (setsize == eventLoop->setsize) return AE_OK;
389 if (eventLoop->maxfd >= setsize) return AE_ERR;
390 if (aeApiResize(eventLoop,setsize) == -1) return AE_ERR;
391
392 eventLoop->events = (aeFileEvent*)zrealloc(eventLoop->events,sizeof(aeFileEvent)*setsize, MALLOC_LOCAL);
393 eventLoop->fired = (aeFiredEvent*)zrealloc(eventLoop->fired,sizeof(aeFiredEvent)*setsize, MALLOC_LOCAL);
394 eventLoop->setsize = setsize;
395
396 /* Make sure that if we created new slots, they are initialized with
397 * an AE_NONE mask. */
398 for (i = eventLoop->maxfd+1; i < setsize; i++)
399 eventLoop->events[i].mask = AE_NONE;
400 return AE_OK;
401}
402
403extern "C" void aeDeleteEventLoop(aeEventLoop *eventLoop) {
404 aeApiFree(eventLoop);

Callers 1

updateMaxclientsFunction · 0.85

Calls 2

zreallocFunction · 0.85
aeApiResizeFunction · 0.70

Tested by

no test coverage detected