Просмотр исходного кода

Fix: only apply SO_NOSIGPIPE on darwin

Rod Hynes 8 лет назад
Родитель
Сommit
81a334b6c6
3 измененных файлов с 54 добавлено и 1 удалено
  1. 1 1
      psiphon/TCPConn_bind.go
  2. 28 0
      psiphon/TCPConn_darwin.go
  3. 25 0
      psiphon/TCPConn_nodarwin.go

+ 1 - 1
psiphon/TCPConn_bind.go

@@ -124,7 +124,7 @@ func tcpDial(addr string, config *DialConfig) (net.Conn, error) {
 			continue
 		}
 
-		syscall.SetsockoptInt(socketFd, syscall.SOL_SOCKET, syscall.SO_NOSIGPIPE, 1)
+		tcpDialSetAdditionalSocketOptions(socketFd)
 
 		if config.DeviceBinder != nil {
 			// WARNING: this potentially violates the direction to not call into

+ 28 - 0
psiphon/TCPConn_darwin.go

@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2017, Psiphon Inc.
+ * All rights reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package psiphon
+
+import (
+	"syscall"
+)
+
+func tcpDialSetAdditionalSocketOptions(socketFd int) {
+	syscall.SetsockoptInt(socketFd, syscall.SOL_SOCKET, syscall.SO_NOSIGPIPE, 1)
+}

+ 25 - 0
psiphon/TCPConn_nodarwin.go

@@ -0,0 +1,25 @@
+// +build !darwin
+
+/*
+ * Copyright (c) 2017, Psiphon Inc.
+ * All rights reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package psiphon
+
+func tcpDialSetAdditionalSocketOptions(_ int) {
+}