diff options
author | Anton Tyurin <noxiouz@yandex.ru> | 2016-06-13 19:00:33 +0400 |
---|---|---|
committer | Aliaksandr Valialkin <valyala@gmail.com> | 2016-06-13 18:00:33 +0300 |
commit | 33ed259db713ef4460de2ad4c9429d5bdc8385fd (patch) | |
tree | d655fb66fe9ca7895a09fdaf16a64fad176f9a2c /reuseport | |
parent | Fix typo (#115) (diff) | |
download | fasthttp-33ed259db713ef4460de2ad4c9429d5bdc8385fd.tar.gz fasthttp-33ed259db713ef4460de2ad4c9429d5bdc8385fd.tar.bz2 fasthttp-33ed259db713ef4460de2ad4c9429d5bdc8385fd.zip |
reuseport: set FD_CLOSEEXEC for the sockets (#117)
Signed-off-by: Anton Tiurin <noxiouz@yandex.ru>
Diffstat (limited to 'reuseport')
-rw-r--r-- | reuseport/reuseport.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/reuseport/reuseport.go b/reuseport/reuseport.go index a3b7aa2..792ba9c 100644 --- a/reuseport/reuseport.go +++ b/reuseport/reuseport.go @@ -60,7 +60,13 @@ func Listen(network, addr string) (l net.Listener, err error) { return nil, err } - if fd, err = syscall.Socket(soType, syscall.SOCK_STREAM, syscall.IPPROTO_TCP); err != nil { + syscall.ForkLock.RLock() + fd, err = syscall.Socket(soType, syscall.SOCK_STREAM, syscall.IPPROTO_TCP) + if err == nil { + syscall.CloseOnExec(fd) + } + syscall.ForkLock.RUnlock() + if err != nil { return nil, err } |