Fix deadlocks in single-upstream mode
This commit is contained in:
parent
aedf66c73d
commit
7714c84669
@ -21,7 +21,7 @@ See the man page at `soju.1.scd` for more information.
|
|||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Send patches on the [mailing list] or on [GitHub], report bugs on the
|
Send patches on the [mailing list] or on [GitHub], report bugs on the
|
||||||
[issue tracker].
|
[issue tracker]. Discuss in #soju on Freenode.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
@ -108,6 +108,7 @@ func newDownstreamConn(srv *Server, netConn net.Conn) *downstreamConn {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
dc.logger.Printf("new connection")
|
||||||
return dc
|
return dc
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,7 +159,7 @@ func (dc *downstreamConn) marshalEntity(uc *upstreamConn, entity string) string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (dc *downstreamConn) marshalChannel(uc *upstreamConn, name string) string {
|
func (dc *downstreamConn) marshalChannel(uc *upstreamConn, name string) string {
|
||||||
if dc.upstream() != nil {
|
if dc.network != nil {
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
return name + "/" + uc.network.GetName()
|
return name + "/" + uc.network.GetName()
|
||||||
@ -195,7 +196,7 @@ func (dc *downstreamConn) marshalNick(uc *upstreamConn, nick string) string {
|
|||||||
if nick == uc.nick {
|
if nick == uc.nick {
|
||||||
return dc.nick
|
return dc.nick
|
||||||
}
|
}
|
||||||
if dc.upstream() != nil {
|
if dc.network != nil {
|
||||||
return nick
|
return nick
|
||||||
}
|
}
|
||||||
return nick + "/" + uc.network.GetName()
|
return nick + "/" + uc.network.GetName()
|
||||||
@ -205,7 +206,7 @@ func (dc *downstreamConn) marshalUserPrefix(uc *upstreamConn, prefix *irc.Prefix
|
|||||||
if prefix.Name == uc.nick {
|
if prefix.Name == uc.nick {
|
||||||
return dc.prefix()
|
return dc.prefix()
|
||||||
}
|
}
|
||||||
if dc.upstream() != nil {
|
if dc.network != nil {
|
||||||
return prefix
|
return prefix
|
||||||
}
|
}
|
||||||
return &irc.Prefix{
|
return &irc.Prefix{
|
||||||
@ -225,8 +226,6 @@ func (dc *downstreamConn) isClosed() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (dc *downstreamConn) readMessages(ch chan<- downstreamIncomingMessage) error {
|
func (dc *downstreamConn) readMessages(ch chan<- downstreamIncomingMessage) error {
|
||||||
dc.logger.Printf("new connection")
|
|
||||||
|
|
||||||
for {
|
for {
|
||||||
msg, err := dc.irc.ReadMessage()
|
msg, err := dc.irc.ReadMessage()
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
@ -664,6 +663,7 @@ func (dc *downstreamConn) register() error {
|
|||||||
|
|
||||||
dc.registered = true
|
dc.registered = true
|
||||||
dc.username = dc.user.Username
|
dc.username = dc.user.Username
|
||||||
|
dc.logger.Printf("registration complete for user %q", dc.username)
|
||||||
|
|
||||||
dc.user.lock.Lock()
|
dc.user.lock.Lock()
|
||||||
firstDownstream := len(dc.user.downstreamConns) == 0
|
firstDownstream := len(dc.user.downstreamConns) == 0
|
||||||
|
Loading…
Reference in New Issue
Block a user