Mercurial > hg > nginx
comparison src/http/ngx_http.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 | 3c344ea7d88b |
children | 78c06e5e1d76 |
comparison
equal
deleted
inserted
replaced
6152:3c344ea7d88b | 6153:4f6efabcb09b |
---|---|
1735 return NGX_ERROR; | 1735 return NGX_ERROR; |
1736 } | 1736 } |
1737 break; | 1737 break; |
1738 } | 1738 } |
1739 | 1739 |
1740 if (ngx_clone_listening(cf, ls) != NGX_OK) { | |
1741 return NGX_ERROR; | |
1742 } | |
1743 | |
1740 addr++; | 1744 addr++; |
1741 last--; | 1745 last--; |
1742 } | 1746 } |
1743 | 1747 |
1744 return NGX_OK; | 1748 return NGX_OK; |
1811 ls->setfib = addr->opt.setfib; | 1815 ls->setfib = addr->opt.setfib; |
1812 #endif | 1816 #endif |
1813 | 1817 |
1814 #if (NGX_HAVE_TCP_FASTOPEN) | 1818 #if (NGX_HAVE_TCP_FASTOPEN) |
1815 ls->fastopen = addr->opt.fastopen; | 1819 ls->fastopen = addr->opt.fastopen; |
1820 #endif | |
1821 | |
1822 #if (NGX_HAVE_REUSEPORT) | |
1823 ls->reuseport = addr->opt.reuseport; | |
1816 #endif | 1824 #endif |
1817 | 1825 |
1818 return ls; | 1826 return ls; |
1819 } | 1827 } |
1820 | 1828 |