Source file src/net/internal/socktest/switch_unix.go
Documentation: net/internal/socktest
1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build aix || darwin || dragonfly || freebsd || (js && wasm) || linux || netbsd || openbsd || solaris 6 // +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solaris 7 8 package socktest 9 10 // Sockets maps a socket descriptor to the status of socket. 11 type Sockets map[int]Status 12 13 func (sw *Switch) sockso(s int) *Status { 14 sw.smu.RLock() 15 defer sw.smu.RUnlock() 16 so, ok := sw.sotab[s] 17 if !ok { 18 return nil 19 } 20 return &so 21 } 22 23 // addLocked returns a new Status without locking. 24 // sw.smu must be held before call. 25 func (sw *Switch) addLocked(s, family, sotype, proto int) *Status { 26 sw.once.Do(sw.init) 27 so := Status{Cookie: cookie(family, sotype, proto)} 28 sw.sotab[s] = so 29 return &so 30 } 31