comparison src/event/modules/ngx_epoll_module.c @ 5707:31dd63dcb9ea

Events: use eventfd() instead of syscall(SYS_eventfd) if possible. This fixes --with-file-aio support on systems that lack eventfd() syscall, notably aarch64 Linux. The syscall(SYS_eventfd) may still be necessary on systems that have eventfd() syscall in the kernel but lack it in glibc, e.g. as seen in the current CentOS 5 release.
author Ruslan Ermilov <ru@nginx.com>
date Fri, 23 May 2014 16:37:05 +0400
parents 36b58ddb566d
children 3377f9459e99
comparison
equal deleted inserted replaced
5706:a2bf26774cd3 5707:31dd63dcb9ea
191 191
192 /* 192 /*
193 * We call io_setup(), io_destroy() io_submit(), and io_getevents() directly 193 * We call io_setup(), io_destroy() io_submit(), and io_getevents() directly
194 * as syscalls instead of libaio usage, because the library header file 194 * as syscalls instead of libaio usage, because the library header file
195 * supports eventfd() since 0.3.107 version only. 195 * supports eventfd() since 0.3.107 version only.
196 *
197 * Also we do not use eventfd() in glibc, because glibc supports it
198 * since 2.8 version and glibc maps two syscalls eventfd() and eventfd2()
199 * into single eventfd() function with different number of parameters.
200 */ 196 */
201 197
202 static int 198 static int
203 io_setup(u_int nr_reqs, aio_context_t *ctx) 199 io_setup(u_int nr_reqs, aio_context_t *ctx)
204 { 200 {
225 ngx_epoll_aio_init(ngx_cycle_t *cycle, ngx_epoll_conf_t *epcf) 221 ngx_epoll_aio_init(ngx_cycle_t *cycle, ngx_epoll_conf_t *epcf)
226 { 222 {
227 int n; 223 int n;
228 struct epoll_event ee; 224 struct epoll_event ee;
229 225
226 #if (NGX_HAVE_SYS_EVENTFD_H)
227 ngx_eventfd = eventfd(0, 0);
228 #else
230 ngx_eventfd = syscall(SYS_eventfd, 0); 229 ngx_eventfd = syscall(SYS_eventfd, 0);
230 #endif
231 231
232 if (ngx_eventfd == -1) { 232 if (ngx_eventfd == -1) {
233 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, 233 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
234 "eventfd() failed"); 234 "eventfd() failed");
235 ngx_file_aio = 0; 235 ngx_file_aio = 0;