static int init_evports_per_thread() { int fd; evports_evlist_max = global.tune.maxpollevents; evports_evlist = calloc(evports_evlist_max, sizeof (port_event_t)); if (evports_evlist == NULL) { goto fail_alloc; } if (MAX_THREADS > 1 && tid) { if ((evports_fd[tid] = port_create()) == -1) { goto fail_fd; } } /* we may have to unregister some events initially registered on the * original fd when it was alone, and/or to register events on the new * fd for this thread. Let's just mark them as updated, the poller will * do the rest. */ for (fd = 0; fd < global.maxsock; fd++) updt_fd_polling(fd); return 1; fail_fd: free(evports_evlist); evports_evlist = NULL; evports_evlist_max = 0; fail_alloc: return 0; }
static int init_epoll_per_thread() { int fd; epoll_events = calloc(1, sizeof(struct epoll_event) * global.tune.maxpollevents); if (epoll_events == NULL) goto fail_alloc; if (MAX_THREADS > 1 && tid) { epoll_fd[tid] = epoll_create(global.maxsock + 1); if (epoll_fd[tid] < 0) goto fail_fd; } /* we may have to unregister some events initially registered on the * original fd when it was alone, and/or to register events on the new * fd for this thread. Let's just mark them as updated, the poller will * do the rest. */ for (fd = 0; fd < global.maxsock; fd++) updt_fd_polling(fd); return 1; fail_fd: free(epoll_events); fail_alloc: return 0; }