core: put more intelligence into `queue_msg()`
core: put more intelligence into `queue_msg()`

Fixes #1942.

There were two instances were it was not checked the target thread has a
message queue before queuing the message.

This PR centralizes the check into `queue_msg()`.

aeneby/RIOT,rfuentess/RIOT,mtausig/RIOT,centurysys/RIOT,kerneltask/RIOT,changbiao/RIOT,gbarnett/RIOT,jferreir/RIOT,Yonezawa-T2/RIOT,basilfx/RIOT,rajma996/RIOT,kushalsingh007/RIOT,kaleb-himes/RIOT,sumanpanchal/RIOT,mziegert/RIOT,rajma996/RIOT,OTAkeys/RIOT,rajma996/RIOT,yogo1212/RIOT,sumanpanchal/RIOT,tfar/RIOT,LudwigOrtmann/RIOT,koenning/RIOT,sgso/RIOT,rfswarm/RIOT,kb2ma/RIOT,gautric/RIOT,jferreir/RIOT,tfar/RIOT,altairpearl/RIOT,wentaoshang/RIOT,mziegert/RIOT,BytesGalore/RIOT,jbeyerstedt/RIOT-OTA-update,alex1818/RIOT,thiagohd/RIOT,phiros/RIOT,lebrush/RIOT,daniel-k/RIOT,tfar/RIOT,ThanhVic/RIOT,lazytech-org/RIOT,emmanuelsearch/RIOT,jasonatran/RIOT,patkan/RIOT,phiros/RIOT,lazytech-org/RIOT,malosek/RIOT,watr-li/RIOT,backenklee/RIOT,openkosmosorg/RIOT,mfrey/RIOT,automote/RIOT,JensErdmann/RIOT,RubikonAlpha/RIOT,MonsterCode8000/RIOT,abkam07/RIOT,JensErdmann/RIOT,msolters/RIOT,Osblouf/RIOT,authmillenon/RIOT,TobiasFredersdorf/RIOT,fnack/RIOT,mziegert/RIOT,A-Paul/RIOT,phiros/RIOT,rousselk/RIOT,neiljay/RIOT,josephnoir/RIOT,benoit-canet/RIOT,robixnai/RIOT,kerneltask/RIOT,katezilla/RIOT,Josar/RIOT,toonst/RIOT,beurdouche/RIOT,chris-wood/RIOT,JensErdmann/RIOT,robixnai/RIOT,marcosalm/RIOT,haoyangyu/RIOT,asanka-code/RIOT,jremmert-phytec-iot/RIOT,abkam07/RIOT,Josar/RIOT,gbarnett/RIOT,RBartz/RIOT,Lexandro92/RIOT-CoAP,dkm/RIOT,mtausig/RIOT,RBartz/RIOT,Lexandro92/RIOT-CoAP,PSHIVANI/Riot-Code,benoit-canet/RIOT,cladmi/RIOT,dailab/RIOT,luciotorre/RIOT,syin2/RIOT,thiagohd/RIOT,LudwigOrtmann/RIOT,herrfz/RIOT-old,emmanuelsearch/RIOT,thiagohd/RIOT,MohmadAyman/RIOT,zhuoshuguo/RIOT,josephnoir/RIOT,JensErdmann/RIOT,changbiao/RIOT,latsku/RIOT,gbarnett/RIOT,neiljay/RIOT,roberthartung/RIOT,x3ro/RIOT,ntrtrung/RIOT,d00616/RIOT,lebrush/RIOT,MonsterCode8000/RIOT,changbiao/RIOT,biboc/RIOT,tdautc19841202/RIOT,kerneltask/RIOT,gbarnett/RIOT,kushalsingh007/RIOT,foss-for-synopsys-dwc-arc-processors/RIOT,cladmi/RIOT,patkan/RIOT,lazytech-org/RIOT,bartfaizoltan/RIOT,sgso/RIOT,AnonMall/RIOT,Darredevil/RIOT,binarylemon/RIOT,latsku/RIOT,1blankz7/RIOT,rakendrathapa/RIOT,latsku/RIOT,josephnoir/RIOT,zhuoshuguo/RIOT,ant9000/RIOT,marcosalm/RIOT,Darredevil/RIOT,adrianghc/RIOT,jferreir/RIOT,hamilton-mote/RIOT-OS,luciotorre/RIOT,beurdouche/RIOT,centurysys/RIOT,stevenj/RIOT,LudwigOrtmann/RIOT,chris-wood/RIOT,Josar/RIOT,rfswarm2/RIOT,ntrtrung/RIOT,RBartz/RIOT,basilfx/RIOT,rajma996/RIOT,hamilton-mote/RIOT-OS,dkm/RIOT,RubikonAlpha/RIOT,RIOT-OS/RIOT,AnonMall/RIOT,lebrush/RIOT,ThanhVic/RIOT,abp719/RIOT,immesys/RiSyn,syin2/RIOT,kbumsik/RIOT,khhhh/RIOT,dailab/RIOT,asanka-code/RIOT,luciotorre/RIOT,ThanhVic/RIOT,herrfz/RIOT-old,attdona/RIOT,luciotorre/RIOT,roberthartung/RIOT,toonst/RIOT,tdautc19841202/RIOT,neumodisch/RIOT,wentaoshang/RIOT,OTAkeys/RIOT,nsol-nmsu/RIOT,jasonatran/RIOT,yogo1212/RIOT,alignan/RIOT,rfuentess/RIOT,1blankz7/RIOT,rfswarm2/RIOT,automote/RIOT,LudwigOrtmann/RIOT,kb2ma/RIOT,DipSwitch/RIOT,neumodisch/RIOT,Hyungsin/RIOT-OS,emmanuelsearch/RIOT,d00616/RIOT,OlegHahm/RIOT,alex1818/RIOT,miri64/RIOT,binarylemon/RIOT,zhuoshuguo/RIOT,mtausig/RIOT,avmelnikoff/RIOT,smlng/RIOT,adrianghc/RIOT,katezilla/RIOT,altairpearl/RIOT,dhruvvyas90/RIOT,neiljay/RIOT,shady33/RIOT,phiros/RIOT,miri64/RIOT,ks156/RIOT,stevenj/RIOT,centurysys/RIOT,brettswann/RIOT,Yonezawa-T2/RIOT,Yonezawa-T2/RIOT,jfischer-phytec-iot/RIOT,A-Paul/RIOT,tdautc19841202/RIOT,jremmert-phytec-iot/RIOT,jremmert-phytec-iot/RIOT,kushalsingh007/RIOT,gautric/RIOT,centurysys/RIOT,JensErdmann/RIOT,cladmi/RIOT,emmanuelsearch/RIOT,automote/RIOT,MarkXYang/RIOT,fnack/RIOT,neumodisch/RIOT,MarkXYang/RIOT,AnonMall/RIOT,ThanhVic/RIOT,katezilla/RIOT,gautric/RIOT,jfischer-phytec-iot/RIOT,immesys/RiSyn,jferreir/RIOT,bartfaizoltan/RIOT,ximus/RIOT,Lexandro92/RIOT-CoAP,asanka-code/RIOT,alex1818/RIOT,herrfz/RIOT,l3nko/RIOT,koenning/RIOT,beurdouche/RIOT,tfar/RIOT,RBartz/RIOT,EmuxEvans/RIOT,jasonatran/RIOT,mtausig/RIOT,jfischer-phytec-iot/RIOT,PSHIVANI/Riot-Code,khhhh/RIOT,BytesGalore/RIOT,LudwigKnuepfer/RIOT,Yonezawa-T2/RIOT,EmuxEvans/RIOT,OlegHahm/RIOT,miri64/RIOT,jhollister/RIOT,haoyangyu/RIOT,rousselk/RIOT,jhollister/RIOT,Ell-i/RIOT,automote/RIOT,dhruvvyas90/RIOT,daniel-k/RIOT,adjih/RIOT,haoyangyu/RIOT,PSHIVANI/Riot-Code,abkam07/RIOT,msolters/RIOT,AnonMall/RIOT,authmillenon/RIOT,altairpearl/RIOT,rakendrathapa/RIOT,yogo1212/RIOT,ximus/RIOT,biboc/RIOT,gebart/RIOT,asanka-code/RIOT,robixnai/RIOT,ant9000/RIOT,abp719/RIOT,LudwigOrtmann/RIOT,smlng/RIOT,rfswarm2/RIOT,PSHIVANI/Riot-Code,rousselk/RIOT,Yonezawa-T2/RIOT,luciotorre/RIOT,kbumsik/RIOT,PSHIVANI/Riot-Code,MonsterCode8000/RIOT,abp719/RIOT,l3nko/RIOT,stevenj/RIOT,phiros/RIOT,binarylemon/RIOT,RIOT-OS/RIOT,PSHIVANI/Riot-Code,ant9000/RIOT,authmillenon/RIOT,RubikonAlpha/RIOT,x3ro/RIOT,automote/RIOT,openkosmosorg/RIOT,AnonMall/RIOT,rfswarm/RIOT,haoyangyu/RIOT,watr-li/RIOT,l3nko/RIOT,shady33/RIOT,kushalsingh007/RIOT,ntrtrung/RIOT,TobiasFredersdorf/RIOT,1blankz7/RIOT,mziegert/RIOT,kaspar030/RIOT,1blankz7/RIOT,MarkXYang/RIOT,marcosalm/RIOT,aeneby/RIOT,authmillenon/RIOT,koenning/RIOT,khhhh/RIOT,biboc/RIOT,RubikonAlpha/RIOT,ximus/RIOT,FrancescoErmini/RIOT,basilfx/RIOT,AnonMall/RIOT,josephnoir/RIOT,kbumsik/RIOT,ntrtrung/RIOT,kYc0o/RIOT,miri64/RIOT,thiagohd/RIOT,herrfz/RIOT-old,herrfz/RIOT,sumanpanchal/RIOT,zhuoshuguo/RIOT,alignan/RIOT,toonst/RIOT,stevenj/RIOT,Ell-i/RIOT,RubikonAlpha/RIOT,watr-li/RIOT,latsku/RIOT,FrancescoErmini/RIOT,robixnai/RIOT,koenning/RIOT,brettswann/RIOT,neiljay/RIOT,patkan/RIOT,sgso/RIOT,Ell-i/RIOT,ks156/RIOT,immesys/RiSyn,lebrush/RIOT,rakendrathapa/RIOT,OTAkeys/RIOT,smlng/RIOT,rakendrathapa/RIOT,wentaoshang/RIOT,koenning/RIOT,kbumsik/RIOT,1blankz7/RIOT,daniel-k/RIOT,A-Paul/RIOT,1blankz7/RIOT,foss-for-synopsys-dwc-arc-processors/RIOT,herrfz/RIOT,adjih/RIOT,malosek/RIOT,latsku/RIOT,rfuentess/RIOT,rakendrathapa/RIOT,roberthartung/RIOT,ant9000/RIOT,A-Paul/RIOT,rakendrathapa/RIOT,attdona/RIOT,abkam07/RIOT,immesys/RiSyn,d00616/RIOT,adjih/RIOT,MarkXYang/RIOT,altairpearl/RIOT,alignan/RIOT,DipSwitch/RIOT,rousselk/RIOT,msolters/RIOT,basilfx/RIOT,jasonatran/RIOT,kerneltask/RIOT,chris-wood/RIOT,thomaseichinger/RIOT,malosek/RIOT,jbeyerstedt/RIOT-OTA-update,josephnoir/RIOT,Osblouf/RIOT,lebrush/RIOT,thomaseichinger/RIOT,tdautc19841202/RIOT,kushalsingh007/RIOT,msolters/RIOT,MonsterCode8000/RIOT,jbeyerstedt/RIOT-OTA-update,dhruvvyas90/RIOT,Yonezawa-T2/RIOT,dkm/RIOT,stevenj/RIOT,gebart/RIOT,aeneby/RIOT,kaleb-himes/RIOT,gebart/RIOT,TobiasFredersdorf/RIOT,FrancescoErmini/RIOT,aeneby/RIOT,avmelnikoff/RIOT,syin2/RIOT,nsol-nmsu/RIOT,OlegHahm/RIOT,FrancescoErmini/RIOT,DipSwitch/RIOT,LudwigOrtmann/RIOT,ximus/RIOT,jasonatran/RIOT,abkam07/RIOT,malosek/RIOT,l3nko/RIOT,chris-wood/RIOT,jhollister/RIOT,katezilla/RIOT,fnack/RIOT,bartfaizoltan/RIOT,x3ro/RIOT,bartfaizoltan/RIOT,ant9000/RIOT,neumodisch/RIOT,kYc0o/RIOT,shady33/RIOT,kaspar030/RIOT,MonsterCode8000/RIOT,cladmi/RIOT,patkan/RIOT,alignan/RIOT,avmelnikoff/RIOT,neumodisch/RIOT,syin2/RIOT,biboc/RIOT,kYc0o/RIOT,ThanhVic/RIOT,hamilton-mote/RIOT-OS,khhhh/RIOT,adrianghc/RIOT,tdautc19841202/RIOT,ximus/RIOT,bartfaizoltan/RIOT,Osblouf/RIOT,alex1818/RIOT,TobiasFredersdorf/RIOT,herrfz/RIOT-old,dhruvvyas90/RIOT,mfrey/RIOT,foss-for-synopsys-dwc-arc-processors/RIOT,MohmadAyman/RIOT,jfischer-phytec-iot/RIOT,toonst/RIOT,robixnai/RIOT,cladmi/RIOT,neumodisch/RIOT,altairpearl/RIOT,jremmert-phytec-iot/RIOT,Darredevil/RIOT,thomaseichinger/RIOT,shady33/RIOT,plushvoxel/RIOT,authmillenon/RIOT,kYc0o/RIOT,Ell-i/RIOT,arvindpdmn/RIOT,dailab/RIOT,attdona/RIOT,ntrtrung/RIOT,kaspar030/RIOT,Lexandro92/RIOT-CoAP,rousselk/RIOT,mziegert/RIOT,sumanpanchal/RIOT,kaleb-himes/RIOT,openkosmosorg/RIOT,l3nko/RIOT,gautric/RIOT,shady33/RIOT,roberthartung/RIOT,kb2ma/RIOT,alex1818/RIOT,MohmadAyman/RIOT,MonsterCode8000/RIOT,toonst/RIOT,EmuxEvans/RIOT,avmelnikoff/RIOT,Osblouf/RIOT,zhuoshuguo/RIOT,sgso/RIOT,lebrush/RIOT,bartfaizoltan/RIOT,thomaseichinger/RIOT,RubikonAlpha/RIOT,herrfz/RIOT-old,ximus/RIOT,Hyungsin/RIOT-OS,Hyungsin/RIOT-OS,dailab/RIOT,Hyungsin/RIOT-OS,abp719/RIOT,sgso/RIOT,adrianghc/RIOT,beurdouche/RIOT,smlng/RIOT,BytesGalore/RIOT,EmuxEvans/RIOT,kerneltask/RIOT,OTAkeys/RIOT,kushalsingh007/RIOT,watr-li/RIOT,jbeyerstedt/RIOT-OTA-update,avmelnikoff/RIOT,mfrey/RIOT,fnack/RIOT,dkm/RIOT,nsol-nmsu/RIOT,herrfz/RIOT,khhhh/RIOT,jhollister/RIOT,Lexandro92/RIOT-CoAP,RIOT-OS/RIOT,adjih/RIOT,marcosalm/RIOT,kb2ma/RIOT,emmanuelsearch/RIOT,MohmadAyman/RIOT,malosek/RIOT,jbeyerstedt/RIOT-OTA-update,daniel-k/RIOT,changbiao/RIOT,backenklee/RIOT,sgso/RIOT,attdona/RIOT,herrfz/RIOT,immesys/RiSyn,authmillenon/RIOT,kbumsik/RIOT,rfswarm/RIOT,openkosmosorg/RIOT,khhhh/RIOT,chris-wood/RIOT,RIOT-OS/RIOT,latsku/RIOT,jfischer-phytec-iot/RIOT,haoyangyu/RIOT,A-Paul/RIOT,EmuxEvans/RIOT,herrfz/RIOT,rajma996/RIOT,daniel-k/RIOT,arvindpdmn/RIOT,kYc0o/RIOT,Darredevil/RIOT,BytesGalore/RIOT,MohmadAyman/RIOT,thiagohd/RIOT,wentaoshang/RIOT,arvindpdmn/RIOT,changbiao/RIOT,benoit-canet/RIOT,lazytech-org/RIOT,Darredevil/RIOT,thomaseichinger/RIOT,daniel-k/RIOT,watr-li/RIOT,kaspar030/RIOT,fnack/RIOT,backenklee/RIOT,MohmadAyman/RIOT,Lexandro92/RIOT-CoAP,TobiasFredersdorf/RIOT,dhruvvyas90/RIOT,RBartz/RIOT,beurdouche/RIOT,rfswarm2/RIOT,Darredevil/RIOT,wentaoshang/RIOT,arvindpdmn/RIOT,roberthartung/RIOT,d00616/RIOT,backenklee/RIOT,robixnai/RIOT,rfswarm/RIOT,jhollister/RIOT,chris-wood/RIOT,Josar/RIOT,asanka-code/RIOT,gautric/RIOT,Osblouf/RIOT,rfswarm2/RIOT,EmuxEvans/RIOT,arvindpdmn/RIOT,rfswarm/RIOT,Josar/RIOT,DipSwitch/RIOT,msolters/RIOT,rfswarm/RIOT,malosek/RIOT,yogo1212/RIOT,gbarnett/RIOT,msolters/RIOT,x3ro/RIOT,ThanhVic/RIOT,OlegHahm/RIOT,openkosmosorg/RIOT,jferreir/RIOT,ntrtrung/RIOT,gebart/RIOT,emmanuelsearch/RIOT,dhruvvyas90/RIOT,tfar/RIOT,miri64/RIOT,stevenj/RIOT,rajma996/RIOT,MarkXYang/RIOT,brettswann/RIOT,kaspar030/RIOT,DipSwitch/RIOT,zhuoshuguo/RIOT,plushvoxel/RIOT,benoit-canet/RIOT,attdona/RIOT,wentaoshang/RIOT,asanka-code/RIOT,l3nko/RIOT,rfuentess/RIOT,abp719/RIOT,backenklee/RIOT,lazytech-org/RIOT,basilfx/RIOT,changbiao/RIOT,openkosmosorg/RIOT,mfrey/RIOT,shady33/RIOT,abkam07/RIOT,fnack/RIOT,phiros/RIOT,adrianghc/RIOT,smlng/RIOT,Osblouf/RIOT,koenning/RIOT,binarylemon/RIOT,automote/RIOT,katezilla/RIOT,LudwigKnuepfer/RIOT,Hyungsin/RIOT-OS,LudwigKnuepfer/RIOT,thiagohd/RIOT,adjih/RIOT,d00616/RIOT,luciotorre/RIOT,binarylemon/RIOT,brettswann/RIOT,plushvoxel/RIOT,gebart/RIOT,jferreir/RIOT,jremmert-phytec-iot/RIOT,kb2ma/RIOT,nsol-nmsu/RIOT,syin2/RIOT,gbarnett/RIOT,benoit-canet/RIOT,FrancescoErmini/RIOT,neiljay/RIOT,FrancescoErmini/RIOT,brettswann/RIOT,hamilton-mote/RIOT-OS,tdautc19841202/RIOT,OlegHahm/RIOT,ks156/RIOT,rousselk/RIOT,plushvoxel/RIOT,nsol-nmsu/RIOT,marcosalm/RIOT,RBartz/RIOT,ks156/RIOT,centurysys/RIOT,MarkXYang/RIOT,foss-for-synopsys-dwc-arc-processors/RIOT,binarylemon/RIOT,d00616/RIOT,aeneby/RIOT,mfrey/RIOT,rfuentess/RIOT,ks156/RIOT,rfswarm2/RIOT,LudwigKnuepfer/RIOT,sumanpanchal/RIOT,alex1818/RIOT,altairpearl/RIOT,immesys/RiSyn,alignan/RIOT,LudwigKnuepfer/RIOT,attdona/RIOT,JensErdmann/RIOT,mtausig/RIOT,foss-for-synopsys-dwc-arc-processors/RIOT,BytesGalore/RIOT,DipSwitch/RIOT,centurysys/RIOT,biboc/RIOT,haoyangyu/RIOT,yogo1212/RIOT,patkan/RIOT,arvindpdmn/RIOT,yogo1212/RIOT,dkm/RIOT,kaleb-himes/RIOT,dailab/RIOT,jhollister/RIOT,hamilton-mote/RIOT-OS,patkan/RIOT,mziegert/RIOT,sumanpanchal/RIOT,x3ro/RIOT,RIOT-OS/RIOT,kaleb-himes/RIOT,Ell-i/RIOT,benoit-canet/RIOT,watr-li/RIOT,OTAkeys/RIOT,abp719/RIOT,plushvoxel/RIOT,marcosalm/RIOT,jremmert-phytec-iot/RIOT,brettswann/RIOT