summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-05-20 03:42:57 +0000
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-05-20 05:47:09 +0000
commit2e2d67c967a4a03936ede9c474a8d42739215271 (patch)
tree0cb9559630234db37ffd6d43289c85bf771556b7
parentf811801f1cf20a6da3bfef8c2c96c353d809601a (diff)
server: make active md5ed socket nonblocking
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r--server/sockopt_linux.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/server/sockopt_linux.go b/server/sockopt_linux.go
index 4a68a18d..c764eb04 100644
--- a/server/sockopt_linux.go
+++ b/server/sockopt_linux.go
@@ -69,7 +69,7 @@ func DialTCPTimeoutWithMD5Sig(host string, port int, localAddr, key string, msec
}
la = j
}
- sotype := syscall.SOCK_STREAM | syscall.SOCK_CLOEXEC
+ sotype := syscall.SOCK_STREAM | syscall.SOCK_CLOEXEC | syscall.SOCK_NONBLOCK
proto := 0
fd, err := syscall.Socket(family, sotype, proto)
if err != nil {
@@ -87,6 +87,7 @@ func DialTCPTimeoutWithMD5Sig(host string, port int, localAddr, key string, msec
uintptr(unsafe.Pointer(&t)), unsafe.Sizeof(t), 0); e > 0 {
return nil, os.NewSyscallError("setsockopt", e)
}
+
if err = syscall.SetsockoptInt(fd, syscall.SOL_SOCKET, syscall.SO_BROADCAST, 1); err != nil {
return nil, os.NewSyscallError("setsockopt", err)
}
@@ -121,7 +122,7 @@ func DialTCPTimeoutWithMD5Sig(host string, port int, localAddr, key string, msec
var event syscall.EpollEvent
events := make([]syscall.EpollEvent, 1)
- event.Events = syscall.EPOLLIN
+ event.Events = syscall.EPOLLIN | syscall.EPOLLOUT | syscall.EPOLLPRI
event.Fd = int32(fd)
if e = syscall.EpollCtl(epfd, syscall.EPOLL_CTL_ADD, fd, &event); e != nil {
return nil, e