rpc: keep track of acceptors, and cancel them in StopRPCThreads
rpc: keep track of acceptors, and cancel them in StopRPCThreads

Fixes #4156.

The problem is that the boost::asio::io_service destructor
waits for the acceptors to finish (on windows, and boost 1.55).

Fix this by keeping track of the acceptors and cancelling them before
stopping the event loops.

Rebased-By: Wladimir J. van der Laan <bbc07dc96bb50bf6868a2ddfc4dae14fbed703d9@gmail.com>
Rebased-From: cef4494

PIVX-Project/PIVX,ivansib/sibcoin,pinkevich/dash,48thct2jtnf/P,terracoin/terracoin,xuyangcn/opalcoin,npccoin/npccoin,biblepay/biblepay,world-bank/unpay-core,ticclassic/ic,coinkeeper/2015-06-22_19-00_ziftrcoin,projectinterzone/ITZ,ahmedbodi/test2,HeliumGas/helium,Petr-Economissa/gvidon,HeliumGas/helium,ediston/energi,reddink/reddcoin,Mrs-X/Darknet,schinzelh/dash,worldbit/worldbit,litecoin-project/bitcoinomg,bmp02050/ReddcoinUpdates,ivansib/sibcoin,crowning2/dash,dev1972/Satellitecoin,48thct2jtnf/P,Anoncoin/anoncoin,Vsync-project/Vsync,dmrtsvetkov/flowercoin,dev1972/Satellitecoin,cryptodev35/icash,jmgilbert2/energi,worldbit/worldbit,ahmedbodi/test2,CoinProjects/AmsterdamCoin-v4,skaht/bitcoin,ArgonToken/ArgonToken,PandaPayProject/PandaPay,UdjinM6/dash,Petr-Economissa/gvidon,crowning-/dash,terracoin/terracoin,riecoin/riecoin,dashpay/dash,BlockchainTechLLC/3dcoin,DSPay/DSPay,DGCDev/digitalcoin,gapcoin/gapcoin,reddcoin-project/reddcoin,npccoin/npccoin,kbccoin/kbc,freelion93/mtucicoin,CoinProjects/AmsterdamCoin-v4,slingcoin/sling-market,slingcoin/sling-market,world-bank/unpay-core,ColossusCoinXT/ColossusCoinXT,GroundRod/anoncoin,reddcoin-project/reddcoin,mastercoin-MSC/mastercore,diggcoin/diggcoin,mycointest/owncoin,biblepay/biblepay,ahmedbodi/test2,Mrs-X/Darknet,diggcoin/diggcoin,LIMXTEC/DMDv3,puticcoin/putic,knolza/gamblr,xuyangcn/opalcoin,blood2/bloodcoin-0.9,LIMXTEC/DMDv3,xuyangcn/opalcoin,kbccoin/kbc,rdqw/sscoin,ticclassic/ic,alejandromgk/Lunar,lakepay/lake,Mrs-X/PIVX,riecoin/riecoin,skaht/bitcoin,presstab/PIVX,Anoncoin/anoncoin,coinkeeper/2015-06-22_19-07_digitalcoin,coinkeeper/2015-06-22_19-07_digitalcoin,coinerd/krugercoin,LIMXTEC/DMDv3,nmarley/dash,presstab/PIVX,pelorusjack/BlockDX,mycointest/owncoin,ivansib/sib16,terracoin/terracoin,Vsync-project/Vsync,midnight-miner/LasVegasCoin,midnight-miner/LasVegasCoin,puticcoin/putic,npccoin/npccoin,DGCDev/argentum,nmarley/dash,keesdewit82/LasVegasCoin,DGCDev/argentum,Earlz/renamedcoin,BlockchainTechLLC/3dcoin,DGCDev/argentum,mastercoin-MSC/mastercore,midnight-miner/LasVegasCoin,coinerd/krugercoin,grumpydevelop/singularity,grumpydevelop/singularity,reddink/reddcoin,crowning2/dash,rdqw/sscoin,HeliumGas/helium,dmrtsvetkov/flowercoin,putinclassic/putic,alejandromgk/Lunar,DGCDev/digitalcoin,BlockchainTechLLC/3dcoin,npccoin/npccoin,pelorusjack/BlockDX,bmp02050/ReddcoinUpdates,blood2/bloodcoin-0.9,mobicoins/mobicoin-core,reddcoin-project/reddcoin,crowning-/dash,PIVX-Project/PIVX,ticclassic/ic,ZiftrCOIN/ziftrcoin,dashpay/dash,midnight-miner/LasVegasCoin,world-bank/unpay-core,puticcoin/putic,RyanLucchese/energi,jmgilbert2/energi,crowning2/dash,pelorusjack/BlockDX,coinkeeper/2015-06-22_18-36_darkcoin,pinkevich/dash,oklink-dev/bitcoin_block,UdjinM6/dash,ivansib/sibcoin,litecoin-project/bitcoinomg,nightlydash/darkcoin,mycointest/owncoin,basicincome/unpcoin-core,freelion93/mtucicoin,dev1972/Satellitecoin,reddcoin-project/reddcoin,Bloom-Project/Bloom,PandaPayProject/PandaPay,hophacker/bitcoin_malleability,xuyangcn/opalcoin,inkvisit/sarmacoins,alejandromgk/Lunar,zenywallet/bitzeny,DGCDev/argentum,axelxod/braincoin,oklink-dev/bitcoin_block,hophacker/bitcoin_malleability,rsdevgun16e/energi,DSPay/DSPay,ivansib/sibcoin,Anoncoin/anoncoin,aspirecoin/aspire,dmrtsvetkov/flowercoin,UdjinM6/dash,RyanLucchese/energi,willwray/dash,ionomy/ion,cryptodev35/icash,Petr-Economissa/gvidon,Petr-Economissa/gvidon,PandaPayProject/PandaPay,ArgonToken/ArgonToken,pinkevich/dash,ZiftrCOIN/ziftrcoin,DSPay/DSPay,CoinProjects/AmsterdamCoin-v4,gapcoin/gapcoin,puticcoin/putic,ediston/energi,oklink-dev/bitcoin_block,oklink-dev/bitcoin_block,mycointest/owncoin,alejandromgk/Lunar,litecoin-project/bitcoinomg,ionomy/ion,rsdevgun16e/energi,HeliumGas/helium,dashpay/dash,Bloom-Project/Bloom,keesdewit82/LasVegasCoin,nmarley/dash,putinclassic/putic,GroundRod/anoncoin,grumpydevelop/singularity,coinkeeper/2015-06-22_19-00_ziftrcoin,presstab/PIVX,benzmuircroft/REWIRE.io,freelion93/mtucicoin,jmgilbert2/energi,PandaPayProject/PandaPay,alejandromgk/Lunar,diggcoin/diggcoin,schinzelh/dash,schinzelh/dash,schinzelh/dash,gapcoin/gapcoin,reddcoin-project/reddcoin,worldbit/worldbit,mastercoin-MSC/mastercore,blood2/bloodcoin-0.9,hophacker/bitcoin_malleability,presstab/PIVX,axelxod/braincoin,cryptodev35/icash,Earlz/renamedcoin,crowning-/dash,ZiftrCOIN/ziftrcoin,Darknet-Crypto/Darknet,worldbit/worldbit,Mrs-X/Darknet,puticcoin/putic,kbccoin/kbc,basicincome/unpcoin-core,coinkeeper/2015-06-22_19-00_ziftrcoin,Mrs-X/Darknet,greencoin-dev/digitalcoin,dashpay/dash,ediston/energi,cerebrus29301/crowncoin,schinzelh/dash,nmarley/dash,Mrs-X/PIVX,thelazier/dash,inkvisit/sarmacoins,greencoin-dev/digitalcoin,riecoin/riecoin,coinkeeper/2015-06-22_18-36_darkcoin,mastercoin-MSC/mastercore,jmgilbert2/energi,Anoncoin/anoncoin,willwray/dash,PIVX-Project/PIVX,PandaPayProject/PandaPay,nightlydash/darkcoin,slingcoin/sling-market,Darknet-Crypto/Darknet,biblepay/biblepay,ionomy/ion,willwray/dash,ColossusCoinXT/ColossusCoinXT,bickojima/bitzeny,ionomy/ion,projectinterzone/ITZ,rsdevgun16e/energi,rsdevgun16e/energi,coinkeeper/2015-06-22_19-07_digitalcoin,Earlz/renamedcoin,antcheck/antcoin,bickojima/bitzeny,bickojima/bitzeny,ionomy/ion,benzmuircroft/REWIRE.io,DMDcoin/Diamond,keesdewit82/LasVegasCoin,presstab/PIVX,blood2/bloodcoin-0.9,axelxod/braincoin,diggcoin/diggcoin,mobicoins/mobicoin-core,aspirecoin/aspire,Mrs-X/PIVX,projectinterzone/ITZ,thelazier/dash,diggcoin/diggcoin,ColossusCoinXT/ColossusCoinXT,greencoin-dev/digitalcoin,Darknet-Crypto/Darknet,npccoin/npccoin,LIMXTEC/DMDv3,biblepay/biblepay,basicincome/unpcoin-core,ionomy/ion,cryptodev35/icash,greencoin-dev/digitalcoin,Earlz/renamedcoin,ZiftrCOIN/ziftrcoin,DMDcoin/Diamond,LIMXTEC/DMDv3,UdjinM6/dash,RyanLucchese/energi,freelion93/mtucicoin,jmgilbert2/energi,diggcoin/diggcoin,ticclassic/ic,ivansib/sibcoin,DMDcoin/Diamond,bmp02050/ReddcoinUpdates,Mrs-X/PIVX,kbccoin/kbc,worldbit/worldbit,inkvisit/sarmacoins,rsdevgun16e/energi,PandaPayProject/PandaPay,48thct2jtnf/P,thelazier/dash,oklink-dev/bitcoin_block,greencoin-dev/digitalcoin,biblepay/biblepay,rdqw/sscoin,lakepay/lake,nmarley/dash,xuyangcn/opalcoin,reddcoin-project/reddcoin,knolza/gamblr,ArgonToken/ArgonToken,PIVX-Project/PIVX,ticclassic/ic,basicincome/unpcoin-core,litecoin-project/bitcoinomg,oklink-dev/bitcoin_block,ahmedbodi/test2,coinkeeper/2015-06-22_19-07_digitalcoin,Anoncoin/anoncoin,aspirecoin/aspire,GroundRod/anoncoin,jmgilbert2/energi,pelorusjack/BlockDX,lakepay/lake,cerebrus29301/crowncoin,coinkeeper/2015-06-22_19-00_ziftrcoin,Vsync-project/Vsync,cerebrus29301/crowncoin,ColossusCoinXT/ColossusCoinXT,biblepay/biblepay,PIVX-Project/PIVX,DGCDev/digitalcoin,rdqw/sscoin,biblepay/biblepay,48thct2jtnf/P,pelorusjack/BlockDX,DGCDev/argentum,48thct2jtnf/P,pinkevich/dash,Bloom-Project/Bloom,zenywallet/bitzeny,blood2/bloodcoin-0.9,Bloom-Project/Bloom,GroundRod/anoncoin,LIMXTEC/DMDv3,Bloom-Project/Bloom,cerebrus29301/crowncoin,BlockchainTechLLC/3dcoin,benzmuircroft/REWIRE.io,ivansib/sib16,world-bank/unpay-core,Vsync-project/Vsync,RyanLucchese/energi,Mrs-X/Darknet,knolza/gamblr,keesdewit82/LasVegasCoin,bickojima/bitzeny,antcheck/antcoin,knolza/gamblr,coinkeeper/2015-06-22_18-36_darkcoin,presstab/PIVX,48thct2jtnf/P,axelxod/braincoin,PIVX-Project/PIVX,Mrs-X/PIVX,freelion93/mtucicoin,riecoin/riecoin,Earlz/renamedcoin,zenywallet/bitzeny,biblepay/biblepay,DMDcoin/Diamond,thelazier/dash,cerebrus29301/crowncoin,crowning2/dash,inkvisit/sarmacoins,GroundRod/anoncoin,skaht/bitcoin,kbccoin/kbc,nightlydash/darkcoin,lakepay/lake,Mrs-X/Darknet,reddink/reddcoin,pelorusjack/BlockDX,RyanLucchese/energi,Petr-Economissa/gvidon,ediston/energi,ColossusCoinXT/ColossusCoinXT,bickojima/bitzeny,HeliumGas/helium,coinerd/krugercoin,midnight-miner/LasVegasCoin,dmrtsvetkov/flowercoin,coinerd/krugercoin,lakepay/lake,aspirecoin/aspire,DSPay/DSPay,mastercoin-MSC/mastercore,schinzelh/dash,DGCDev/digitalcoin,hophacker/bitcoin_malleability,knolza/gamblr,skaht/bitcoin,mobicoins/mobicoin-core,rdqw/sscoin,CoinProjects/AmsterdamCoin-v4,ivansib/sibcoin,aspirecoin/aspire,skaht/bitcoin,ivansib/sib16,cerebrus29301/crowncoin,grumpydevelop/singularity,terracoin/terracoin,world-bank/unpay-core,thelazier/dash,basicincome/unpcoin-core,projectinterzone/ITZ,bmp02050/ReddcoinUpdates,antcheck/antcoin,slingcoin/sling-market,inkvisit/sarmacoins,dmrtsvetkov/flowercoin,zenywallet/bitzeny,puticcoin/putic,dmrtsvetkov/flowercoin,inkvisit/sarmacoins,BlockchainTechLLC/3dcoin,pinkevich/dash,PIVX-Project/PIVX,dexX7/mastercore,coinkeeper/2015-06-22_19-00_ziftrcoin,terracoin/terracoin,reddink/reddcoin,grumpydevelop/singularity,Darknet-Crypto/Darknet,ediston/energi,PIVX-Project/PIVX,Darknet-Crypto/Darknet,joroob/reddcoin,gapcoin/gapcoin,nmarley/dash,crowning2/dash,benzmuircroft/REWIRE.io,DGCDev/digitalcoin,RyanLucchese/energi,mycointest/owncoin,rsdevgun16e/energi,crowning-/dash,putinclassic/putic,axelxod/braincoin,CoinProjects/AmsterdamCoin-v4,BlockchainTechLLC/3dcoin,Bloom-Project/Bloom,pinkevich/dash,coinkeeper/2015-06-22_18-36_darkcoin,willwray/dash,axelxod/braincoin,mycointest/owncoin,UdjinM6/dash,ahmedbodi/test2,hophacker/bitcoin_malleability,Vsync-project/Vsync,freelion93/mtucicoin,ivansib/sib16,benzmuircroft/REWIRE.io,ivansib/sib16,DSPay/DSPay,rdqw/sscoin,xuyangcn/opalcoin,willwray/dash,mobicoins/mobicoin-core,dexX7/mastercore,riecoin/riecoin,dev1972/Satellitecoin,dev1972/Satellitecoin,slingcoin/sling-market,alejandromgk/Lunar,reddink/reddcoin,midnight-miner/LasVegasCoin,keesdewit82/LasVegasCoin,lakepay/lake,ticclassic/ic,joroob/reddcoin,antcheck/antcoin,dexX7/mastercore,DMDcoin/Diamond,joroob/reddcoin,ArgonToken/ArgonToken,PIVX-Project/PIVX,antcheck/antcoin,mobicoins/mobicoin-core,ColossusCoinXT/ColossusCoinXT,Darknet-Crypto/Darknet,ArgonToken/ArgonToken,crowning-/dash,nightlydash/darkcoin,Vsync-project/Vsync,Petr-Economissa/gvidon,DMDcoin/Diamond,dev1972/Satellitecoin,npccoin/npccoin,worldbit/worldbit,slingcoin/sling-market,CoinProjects/AmsterdamCoin-v4,grumpydevelop/singularity,dashpay/dash,ediston/energi,projectinterzone/ITZ,bmp02050/ReddcoinUpdates,keesdewit82/LasVegasCoin,putinclassic/putic,benzmuircroft/REWIRE.io,nightlydash/darkcoin,willwray/dash,putinclassic/putic,ZiftrCOIN/ziftrcoin,joroob/reddcoin,dexX7/mastercore,knolza/gamblr,crowning-/dash,cryptodev35/icash,ArgonToken/ArgonToken,joroob/reddcoin,Mrs-X/PIVX,HeliumGas/helium,coinkeeper/2015-06-22_19-07_digitalcoin,nmarley/dash,coinkeeper/2015-06-22_18-36_darkcoin,ahmedbodi/test2,aspirecoin/aspire,ivansib/sib16,antcheck/antcoin,putinclassic/putic,zenywallet/bitzeny,terracoin/terracoin