core: Fix quitting from networks on shutdown
authorManuel Nickschas <sputnick@quassel-irc.org>
Sat, 29 Sep 2018 17:38:43 +0000 (19:38 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 1 Oct 2018 17:06:49 +0000 (19:06 +0200)
commit94461212440b2eaeccdbbbb8a734782e8301280c
treee2b28a6a9b79179a8500650aef99b20930852559
parentddfb1d2574c4bffd180361a80df9b1cd584bb040
core: Fix quitting from networks on shutdown

The previous implementation relied on processEvents() to let the
QUIT command be sent to the IRC server. However, processEvents()
does not guarantee that it processes all events (also in other
threads), and indeed, the previous approach was not reliable.

Fix this by waiting for the networks to emit the disconnected()
signal after requesting the quit. There already is a 10 second
timeout in case the IRC server does not close the socket within
a reasonable time, so rely on that. Also ensure that connect requests
are ignored during shutdown.

With the CoreSession requesting a clean shutdown, we no longer need
a similar handling in CoreNetwork's dtor, so remove this.

See also GH-203 and GH-207, which were previous attempts on getting
this right.
src/core/corenetwork.cpp
src/core/corenetwork.h
src/core/coresession.cpp
src/core/coresession.h