Merge pull request #14 from laanwj/2016_11_request_stop_message_loop
Make it possible to request stop of message loop
This commit is contained in:
commit
8c4ef5617b
|
@ -93,10 +93,19 @@ func (r *Ricochet) processNewConnection(conn net.Conn, service RicochetService)
|
||||||
func (r *Ricochet) ProcessMessages(service RicochetService) {
|
func (r *Ricochet) ProcessMessages(service RicochetService) {
|
||||||
for {
|
for {
|
||||||
oc := <-r.newconns
|
oc := <-r.newconns
|
||||||
|
if oc == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
go r.processConnection(oc, service)
|
go r.processConnection(oc, service)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Request that the ProcessMessages loop is stopped after handling all currently
|
||||||
|
// queued new connections.
|
||||||
|
func (r *Ricochet) RequestStopMessageLoop() {
|
||||||
|
r.newconns <- nil
|
||||||
|
}
|
||||||
|
|
||||||
// ProcessConnection starts a blocking process loop which continually waits for
|
// ProcessConnection starts a blocking process loop which continually waits for
|
||||||
// new messages to arrive from the connection and uses the given RicochetService
|
// new messages to arrive from the connection and uses the given RicochetService
|
||||||
// to process them.
|
// to process them.
|
||||||
|
|
|
@ -40,7 +40,7 @@ func (nr *NetworkResolver) Resolve(hostname string) (net.Conn, string, error) {
|
||||||
|
|
||||||
torDialer, err := proxy.SOCKS5("tcp", "127.0.0.1:9050", nil, proxy.Direct)
|
torDialer, err := proxy.SOCKS5("tcp", "127.0.0.1:9050", nil, proxy.Direct)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil,"", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
conn, err := torDialer.Dial("tcp", resolvedHostname+".onion:9878")
|
conn, err := torDialer.Dial("tcp", resolvedHostname+".onion:9878")
|
||||||
|
|
Loading…
Reference in New Issue