فهرست منبع

Fix: socket file descriptor leak
- Also change error message for clarity

Rod Hynes 8 سال پیش
والد
کامیت
14f2c84522
1فایلهای تغییر یافته به همراه3 افزوده شده و 1 حذف شده
  1. 3 1
      psiphon/TCPConn_bind.go

+ 3 - 1
psiphon/TCPConn_bind.go

@@ -165,11 +165,13 @@ func tcpDial(addr string, config *DialConfig) (net.Conn, error) {
 
 		err = goselect.Select(socketFd+1, nil, fdset, nil, timeout)
 		if err != nil {
+			syscall.Close(socketFd)
 			lastErr = common.ContextError(err)
 			continue
 		}
 		if !fdset.IsSet(uintptr(socketFd)) {
-			lastErr = common.ContextError(errors.New("file descriptor not set"))
+			syscall.Close(socketFd)
+			lastErr = common.ContextError(errors.New("connect timed out"))
 			continue
 		}