comparison src/event/ngx_event.c @ 6153:4f6efabcb09b

The "reuseport" option of the "listen" directive. When configured, an individual listen socket on a given address is created for each worker process. This allows to reduce in-kernel lock contention on configurations with high accept rates, resulting in better performance. As of now it works on Linux and DragonFly BSD. Note that on Linux incoming connection requests are currently tied up to a specific listen socket, and if some sockets are closed, connection requests will be reset, see https://lwn.net/Articles/542629/. With nginx, this may happen if the number of worker processes is reduced. There is no such problem on DragonFly BSD. Based on previous work by Sepherosa Ziehau and Yingqi Lu.
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 20 May 2015 15:51:56 +0300
parents b19350b896bb
children 193bbc006d5e
comparison
equal deleted inserted replaced
6152:3c344ea7d88b 6153:4f6efabcb09b
723 /* for each listening socket */ 723 /* for each listening socket */
724 724
725 ls = cycle->listening.elts; 725 ls = cycle->listening.elts;
726 for (i = 0; i < cycle->listening.nelts; i++) { 726 for (i = 0; i < cycle->listening.nelts; i++) {
727 727
728 #if (NGX_HAVE_REUSEPORT)
729 if (ls[i].reuseport && ls[i].worker != ngx_worker) {
730 continue;
731 }
732 #endif
733
728 c = ngx_get_connection(ls[i].fd, cycle->log); 734 c = ngx_get_connection(ls[i].fd, cycle->log);
729 735
730 if (c == NULL) { 736 if (c == NULL) {
731 return NGX_ERROR; 737 return NGX_ERROR;
732 } 738 }