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. */
| 123 | * |
| 124 | * Otherwise AE_OK is returned and the operation is successful. */ |
| 125 | int aeResizeSetSize(aeEventLoop *eventLoop, int setsize) { |
| 126 | int i; |
| 127 | |
| 128 | if (setsize == eventLoop->setsize) return AE_OK; |
| 129 | if (eventLoop->maxfd >= setsize) return AE_ERR; |
| 130 | if (aeApiResize(eventLoop,setsize) == -1) return AE_ERR; |
| 131 | |
| 132 | eventLoop->events = zrealloc(eventLoop->events,sizeof(aeFileEvent)*setsize); |
| 133 | eventLoop->fired = zrealloc(eventLoop->fired,sizeof(aeFiredEvent)*setsize); |
| 134 | eventLoop->setsize = setsize; |
| 135 | |
| 136 | /* Make sure that if we created new slots, they are initialized with |
| 137 | * an AE_NONE mask. */ |
| 138 | for (i = eventLoop->maxfd+1; i < setsize; i++) |
| 139 | eventLoop->events[i].mask = AE_NONE; |
| 140 | return AE_OK; |
| 141 | } |
| 142 | |
| 143 | void aeDeleteEventLoop(aeEventLoop *eventLoop) { |
| 144 | aeApiFree(eventLoop); |
no test coverage detected