Stop dereferencing *conn
The *conn pointer returned by newConn is dereferenced in newDownstreamConn and connectToUpstream (a premature optimization). As a result, the whole struct is copied and the internal newConn goroutine works with a different chunk of memory than downstreamConn and upstreamConn.
This commit is contained in:
parent
a3716dc2d2
commit
d65c1654b8
|
@ -328,7 +328,7 @@ func serverSASLMechanisms(srv *Server) []string {
|
|||
}
|
||||
|
||||
type downstreamConn struct {
|
||||
conn
|
||||
*conn
|
||||
|
||||
id uint64
|
||||
|
||||
|
@ -363,7 +363,7 @@ func newDownstreamConn(srv *Server, ic ircConn, id uint64) *downstreamConn {
|
|||
options := connOptions{Logger: logger}
|
||||
cm := xirc.CaseMappingASCII
|
||||
dc := &downstreamConn{
|
||||
conn: *newConn(srv, ic, &options),
|
||||
conn: newConn(srv, ic, &options),
|
||||
id: id,
|
||||
nick: "*",
|
||||
nickCM: "*",
|
||||
|
|
|
@ -191,7 +191,7 @@ type pendingUpstreamCommand struct {
|
|||
}
|
||||
|
||||
type upstreamConn struct {
|
||||
conn
|
||||
*conn
|
||||
|
||||
network *network
|
||||
user *user
|
||||
|
@ -353,7 +353,7 @@ func connectToUpstream(ctx context.Context, network *network) (*upstreamConn, er
|
|||
|
||||
cm := stdCaseMapping
|
||||
uc := &upstreamConn{
|
||||
conn: *newConn(network.user.srv, newNetIRCConn(netConn), &options),
|
||||
conn: newConn(network.user.srv, newNetIRCConn(netConn), &options),
|
||||
network: network,
|
||||
user: network.user,
|
||||
channels: xirc.NewCaseMappingMap[*upstreamChannel](cm),
|
||||
|
|
Loading…
Reference in a new issue