1
2
3
4
5 package socktest
6
7 import "syscall"
8
9
10 type Sockets map[syscall.Handle]Status
11
12 func (sw *Switch) sockso(s syscall.Handle) *Status {
13 sw.smu.RLock()
14 defer sw.smu.RUnlock()
15 so, ok := sw.sotab[s]
16 if !ok {
17 return nil
18 }
19 return &so
20 }
21
22
23
24 func (sw *Switch) addLocked(s syscall.Handle, family, sotype, proto int) *Status {
25 sw.once.Do(sw.init)
26 so := Status{Cookie: cookie(family, sotype, proto)}
27 sw.sotab[s] = so
28 return &so
29 }
30
View as plain text