add a newConn function that returns a pointer to a Conn with atomics properly initialized

This commit is contained in:
Arceliar 2019-04-26 18:07:57 -05:00
parent 75130f7735
commit 0059baf36c
4 changed files with 30 additions and 28 deletions

View file

@ -456,14 +456,7 @@ func (ss *sessions) handlePing(ping *sessionPing) {
// Check and see if there's a Listener waiting to accept connections
// TODO: this should not block if nothing is accepting
if !ping.IsPong && ss.listener != nil {
conn := &Conn{
core: ss.core,
session: sinfo,
mutex: &sync.RWMutex{},
nodeID: crypto.GetNodeID(&sinfo.theirPermPub),
nodeMask: &crypto.NodeID{},
searchwait: make(chan interface{}),
}
conn := newConn(ss.core, crypto.GetNodeID(&sinfo.theirPermPub), &crypto.NodeID{}, sinfo)
for i := range conn.nodeMask {
conn.nodeMask[i] = 0xFF
}