Rod Hynes 6 лет назад
Родитель
Сommit
4034064568

+ 1 - 1
psiphon/common/osl/osl.go

@@ -495,7 +495,7 @@ func (state *ClientSeedState) sendIssueSLOKsSignal() {
 
 	if state.signalIssueSLOKs != nil {
 		select {
-		case state.signalIssueSLOKs <- *new(struct{}):
+		case state.signalIssueSLOKs <- struct{}{}:
 		default:
 		}
 	}

+ 2 - 2
psiphon/common/tun/tun_test.go

@@ -431,7 +431,7 @@ func (conn *signalConn) Read(p []byte) (n int, err error) {
 	if err != nil {
 		_ = conn.Conn.Close()
 		select {
-		case conn.ioErrorSignal <- *new(struct{}):
+		case conn.ioErrorSignal <- struct{}{}:
 		default:
 		}
 	}
@@ -443,7 +443,7 @@ func (conn *signalConn) Write(p []byte) (n int, err error) {
 	if err != nil {
 		_ = conn.Conn.Close()
 		select {
-		case conn.ioErrorSignal <- *new(struct{}):
+		case conn.ioErrorSignal <- struct{}{}:
 		default:
 		}
 	}

+ 5 - 5
psiphon/controller.go

@@ -328,7 +328,7 @@ func (controller *Controller) ImportExchangePayload(payload string) bool {
 	}
 
 	select {
-	case controller.signalRestartEstablishing <- *new(struct{}):
+	case controller.signalRestartEstablishing <- struct{}{}:
 	default:
 	}
 
@@ -509,7 +509,7 @@ func (controller *Controller) startOrSignalConnectedReporter() {
 		go controller.connectedReporter()
 	} else {
 		select {
-		case controller.signalReportConnected <- *new(struct{}):
+		case controller.signalReportConnected <- struct{}{}:
 		default:
 		}
 	}
@@ -820,7 +820,7 @@ loop:
 // fetch, as the new SLOK may be sufficient to access new OSLs.
 func (controller *Controller) SignalSeededNewSLOK() {
 	select {
-	case controller.signalFetchObfuscatedServerLists <- *new(struct{}):
+	case controller.signalFetchObfuscatedServerLists <- struct{}{}:
 	default:
 	}
 }
@@ -1046,7 +1046,7 @@ func (controller *Controller) triggerFetches() {
 	// TODO: synchronize the fetch response, so it can be incorporated
 	// into the server entry iterator as soon as available.
 	select {
-	case controller.signalFetchCommonRemoteServerList <- *new(struct{}):
+	case controller.signalFetchCommonRemoteServerList <- struct{}{}:
 	default:
 	}
 
@@ -1054,7 +1054,7 @@ func (controller *Controller) triggerFetches() {
 	// so that if one out of the common RLS and OSL set is large, it doesn't
 	// doesn't entirely block fetching the other.
 	select {
-	case controller.signalFetchObfuscatedServerLists <- *new(struct{}):
+	case controller.signalFetchObfuscatedServerLists <- struct{}{}:
 	default:
 	}
 

+ 5 - 5
psiphon/controller_test.go

@@ -630,7 +630,7 @@ func controllerRun(t *testing.T, runConfig *controllerRunConfig) {
 						t.Fatalf("tunnel established unexpectedly")
 					} else {
 						select {
-						case tunnelEstablished <- *new(struct{}):
+						case tunnelEstablished <- struct{}{}:
 						default:
 						}
 					}
@@ -644,14 +644,14 @@ func controllerRun(t *testing.T, runConfig *controllerRunConfig) {
 			case "ClientUpgradeDownloaded":
 
 				select {
-				case upgradeDownloaded <- *new(struct{}):
+				case upgradeDownloaded <- struct{}{}:
 				default:
 				}
 
 			case "ClientIsLatestVersion":
 
 				select {
-				case confirmedLatestVersion <- *new(struct{}):
+				case confirmedLatestVersion <- struct{}{}:
 				default:
 				}
 
@@ -669,7 +669,7 @@ func controllerRun(t *testing.T, runConfig *controllerRunConfig) {
 				if url == config.RemoteServerListUrl {
 					t.Logf("RemoteServerListResourceDownloaded")
 					select {
-					case remoteServerListDownloaded <- *new(struct{}):
+					case remoteServerListDownloaded <- struct{}{}:
 					default:
 					}
 				}
@@ -699,7 +699,7 @@ func controllerRun(t *testing.T, runConfig *controllerRunConfig) {
 		shutdownOk := make(chan struct{}, 1)
 		go func() {
 			controllerWaitGroup.Wait()
-			shutdownOk <- *new(struct{})
+			shutdownOk <- struct{}{}
 		}()
 
 		select {

+ 4 - 4
psiphon/dataStoreRecovery_test.go

@@ -95,12 +95,12 @@ func TestBoltResiliency(t *testing.T) {
 					t.Fatalf("unexpected server entry count: %d", count)
 				}
 				select {
-				case noticeCandidateServers <- *new(struct{}):
+				case noticeCandidateServers <- struct{}{}:
 				default:
 				}
 			case "Exiting":
 				select {
-				case noticeExiting <- *new(struct{}):
+				case noticeExiting <- struct{}{}:
 				default:
 				}
 			case "Alert":
@@ -113,7 +113,7 @@ func TestBoltResiliency(t *testing.T) {
 				}
 				if channel != nil {
 					select {
-					case channel <- *new(struct{}):
+					case channel <- struct{}{}:
 					default:
 					}
 				}
@@ -127,7 +127,7 @@ func TestBoltResiliency(t *testing.T) {
 	drainNoticeChannel := func(channel chan struct{}) {
 		for {
 			select {
-			case channel <- *new(struct{}):
+			case channel <- struct{}{}:
 			default:
 				return
 			}

+ 1 - 1
psiphon/meekConn.go

@@ -989,7 +989,7 @@ func (r *readCloseSignaller) Read(p []byte) (int, error) {
 
 func (r *readCloseSignaller) Close() error {
 	select {
-	case r.closed <- *new(struct{}):
+	case r.closed <- struct{}{}:
 	default:
 	}
 	return nil

+ 1 - 1
psiphon/packetTunnelTransport.go

@@ -227,7 +227,7 @@ func (p *PacketTunnelTransport) failedChannel(
 	// yet in the failed state, trigger a probe.
 
 	select {
-	case channelTunnel.signalPortForwardFailure <- *new(struct{}):
+	case channelTunnel.signalPortForwardFailure <- struct{}{}:
 	default:
 	}
 

+ 1 - 1
psiphon/remoteServerList_test.go

@@ -430,7 +430,7 @@ func testObfuscatedRemoteServerLists(t *testing.T, omitMD5Sums bool) {
 				printNotice = true
 				count := int(payload["count"].(float64))
 				if count == 1 {
-					tunnelEstablished <- *new(struct{})
+					tunnelEstablished <- struct{}{}
 				}
 			case "RemoteServerListResourceDownloadedBytes":
 				// TODO: check for resumed download for each URL

+ 1 - 1
psiphon/server/meek.go

@@ -728,7 +728,7 @@ func (server *MeekServer) rateLimit(clientIP string) bool {
 
 	if triggerGC {
 		select {
-		case server.rateLimitSignalGC <- *new(struct{}):
+		case server.rateLimitSignalGC <- struct{}{}:
 		default:
 		}
 	}

+ 3 - 3
psiphon/server/server_test.go

@@ -739,7 +739,7 @@ func runServer(t *testing.T, runConfig *runServerConfig) {
 		shutdownOk := make(chan struct{}, 1)
 		go func() {
 			serverWaitGroup.Wait()
-			shutdownOk <- *new(struct{})
+			shutdownOk <- struct{}{}
 		}()
 
 		select {
@@ -991,7 +991,7 @@ func runServer(t *testing.T, runConfig *runServerConfig) {
 		shutdownOk := make(chan struct{}, 1)
 		go func() {
 			controllerWaitGroup.Wait()
-			shutdownOk <- *new(struct{})
+			shutdownOk <- struct{}{}
 		}()
 
 		select {
@@ -1880,7 +1880,7 @@ func paveBlocklistFile(t *testing.T, blocklistFilename string) {
 
 func sendNotificationReceived(c chan<- struct{}) {
 	select {
-	case c <- *new(struct{}):
+	case c <- struct{}{}:
 	default:
 	}
 }

+ 1 - 1
psiphon/server/services.go

@@ -245,7 +245,7 @@ loop:
 			// available in case logServerLoad hangs (which has happened
 			// in the past due to a deadlock bug).
 			select {
-			case signalProcessProfiles <- *new(struct{}):
+			case signalProcessProfiles <- struct{}{}:
 			default:
 			}
 			logServerLoad(tunnelServer)

+ 5 - 5
psiphon/tunnel.go

@@ -403,7 +403,7 @@ func (tunnel *Tunnel) Dial(
 	if result.err != nil {
 		// TODO: conditional on type of error or error message?
 		select {
-		case tunnel.signalPortForwardFailure <- *new(struct{}):
+		case tunnel.signalPortForwardFailure <- struct{}{}:
 		default:
 		}
 		return nil, errors.Trace(result.err)
@@ -427,7 +427,7 @@ func (tunnel *Tunnel) DialPacketTunnelChannel() (net.Conn, error) {
 	if err != nil {
 		// TODO: conditional on type of error or error message?
 		select {
-		case tunnel.signalPortForwardFailure <- *new(struct{}):
+		case tunnel.signalPortForwardFailure <- struct{}{}:
 		default:
 		}
 
@@ -488,7 +488,7 @@ func (conn *TunneledConn) Read(buffer []byte) (n int, err error) {
 		// has a sufficient buffer for the threshold number of reports.
 		// TODO: conditional on type of error or error message?
 		select {
-		case conn.tunnel.signalPortForwardFailure <- *new(struct{}):
+		case conn.tunnel.signalPortForwardFailure <- struct{}{}:
 		default:
 		}
 	}
@@ -500,7 +500,7 @@ func (conn *TunneledConn) Write(buffer []byte) (n int, err error) {
 	if err != nil && err != io.EOF {
 		// Same as TunneledConn.Read()
 		select {
-		case conn.tunnel.signalPortForwardFailure <- *new(struct{}):
+		case conn.tunnel.signalPortForwardFailure <- struct{}{}:
 		default:
 		}
 	}
@@ -1159,7 +1159,7 @@ func (tunnel *Tunnel) operateTunnel(tunnelOwner TunnelOwner) {
 
 		case <-statsTimer.C:
 			select {
-			case signalStatusRequest <- *new(struct{}):
+			case signalStatusRequest <- struct{}{}:
 			default:
 			}
 			statsTimer.Reset(nextStatusRequestPeriod())