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:
Simon Ser 2024-07-08 20:34:01 +02:00
parent a3716dc2d2
commit d65c1654b8
2 changed files with 4 additions and 4 deletions

View file

@ -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: "*",

View file

@ -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),