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. */
| 382 | * |
| 383 | * Otherwise AE_OK is returned and the operation is successful. */ |
| 384 | int 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 | |
| 403 | extern "C" void aeDeleteEventLoop(aeEventLoop *eventLoop) { |
| 404 | aeApiFree(eventLoop); |
no test coverage detected