Fix race accessing plugin storage map
Fix race accessing plugin storage map

`plugins.GetAll()` was not locking the plugin map when checking if a
plugin exists, this can cause a race and potentially a panic if another
goroutine is trying to load a plugin into the map at the same time.

Also fixes a race during activation where a plugin inserts itself into
the plugin map but does not check if something else is already there.
This is already checked before trying to activate the plugin, however
the map lock is not held for this entire period, so other plugins may be
loaded during this time.
To fix, before inserting the plugin into the map, check if one with the
same name already exists and use that instead.

Signed-off-by: Brian Goff <dc73d0991b982a8303e713ef531a313af77e242a@gmail.com>

charleszheng44/moby,miminar/docker,miminar/docker,docker/docker,jimjag/docker,Mokolea/docker,flavio/docker,mixja/docker,JMesser81/docker,pradipd/moby,djs55/docker,shishir-a412ed/docker,jvanz/docker,jimjag/docker,nalind/docker,laijs/moby,bearstech/moby,thtanaka/docker,rhatdan/docker,erikstmartin/docker,qudongfang/docker,laijs/docker,ripcurld0/moby,yummypeng/docker,naveed-jamil-tenpearls/moby,mstanleyjones/docker,Ramzec/docker,HideoYamauchi/docker,ibuildthecloud/docker,moul/docker,tophj-ibm/moby,cpuguy83/docker,ripcurld0/moby,justincormack/docker,Ramzec/docker,dperny/docker,AkihiroSuda/docker,erikstmartin/docker,tmp6154/docker,dmcgowan/docker,moypray/docker,rancher/docker,bearstech/moby,lixiaobing1/docker,jthelin/docker,catinthesky/docker,sterchelen/docker,pramodhkp/moby,KingEmet/docker,mahak/docker,vdemeester/docker,gnailuy/docker,unclejack/docker,mkumatag/docker,duglin/docker,Ramzec/docker,jwhonce/docker,lixiaobing1/docker,ndeloof/docker,qudongfang/docker,danyalKhaliq10p/moby,fcrisciani/docker,estesp/docker,akira-baruah/docker,kolyshkin/moby,kolyshkin/moby,vdemeester/docker,cyphar/docker,thtanaka/docker,lixiaobing1/docker,pramodhkp/moby,mkumatag/docker,jthelin/docker,tmp6154/docker,kolyshkin/docker,shishir-a412ed/docker,amatsus/docker,estesp/docker,ripcurld0/moby,rancher/docker,pradipd/moby,moby/moby,alfred-landrum/docker,kolyshkin/moby,mikedougherty/docker,srust/docker,Mokolea/docker,haveatry/docker,imkin/moby,noironetworks/docker,Syntaxide/docker,michael-holzheu/docker,YuPengZTE/docker,lixiaobing10051267/docker,thtanaka/docker,liaoqingwei/docker,catinthesky/docker,amatsus/docker,darrenstahlmsft/moby,thaJeztah/docker,dccurtis/docker,charleszheng44/moby,johnstep/moby-moby,fcrisciani/docker,tophj-ibm/moby,xuxinkun/docker,dims/docker,ndeloof/docker,prertik/docker,KingEmet/docker,kencochrane/docker,POLJM242/docker,nalind/docker,whuwxl/docker,pradipd/moby,darrenstahlmsft/moby,maxamillion/docker,mikebrow/docker,mike1729/docker,yosifkit/docker,diogomonica/docker,danyalKhaliq10p/moby,yosifkit/docker,q384566678/docker,johnstep/moby-moby,sdurrheimer/docker,yasiramin10p/moby,tklauser/docker,jwhonce/docker,yummypeng/docker,paralin/docker,darrenstahlmsft/docker,ColinHebert/docker,ibuildthecloud/docker,Mokolea/docker,madhanrm/docker,bonczj/moby-json-file-logger,cyphar/docker,rancher/docker,prertik/docker,SvenDowideit/docker,laijs/moby,coolljt0725/docker,konstruktoid/docker-1,dsheets/moby,sarnautov/moby,mtesselH/docker,PatrickLang/moby,laijs/docker,noironetworks/docker,bonczj/moby-json-file-logger,gnailuy/docker,AkihiroSuda/docker,lixiaobing10051267/docker,liaoqingwei/docker,dims/docker,diogomonica/docker,tonistiigi/docker,moypray/docker,mtesselH/docker,maxamillion/docker,mahak/docker,whuwxl/docker,unclejack/docker,srust/docker,mtesselH/docker,coreos/docker,Ramzec/docker,mikebrow/docker,flavio/docker,thaJeztah/docker,sarnautov/moby,kojiromike/docker,resin-io/docker,KarthikNayak/docker,jimjag/docker,konstruktoid/docker-1,mstanleyjones/docker,jameszhan/docker,Syntaxide/docker,michael-holzheu/docker,tianon/docker,crosbymichael/docker,cyphar/docker,konstruktoid/docker-upstream,allencloud/docker,YuPengZTE/docker,q384566678/docker,dgageot/docker,dccurtis/docker,JMesser81/docker,darrenstahlmsft/docker,darrenstahlmsft/moby,shhsu/docker,duglin/docker,mike1729/docker,danyalKhaliq10p/moby,tophj-ibm/moby,ffoysal/docker,dperny/docker,dgageot/docker,tonistiigi/docker,tklauser/docker,hqhq/moby,jlhawn/docker,kojiromike/docker,alfred-landrum/docker,Syntaxide/docker,amatsus/docker,docker/docker,Mokolea/docker,tmp6154/docker,gjaskiewicz/moby,SvenDowideit/docker,yasiramin10p/moby,lixiaobing10051267/docker,ndeloof/docker,pramodhkp/moby,haveatry/docker,coreos/docker,moypray/docker,dgageot/docker,allencloud/docker,JMesser81/docker,ColinHebert/docker,mkumatag/docker,jwhonce/docker,erikh/docker,rhatdan/docker,mike1729/docker,scotttlin/docker,thaJeztah/docker,yasiramin10p/moby,rremer/moby,moby/moby,gschaetz/moby,sterchelen/docker,raja-sami-10p/moby,tklauser/docker,x1022as/docker,mikedougherty/docker,YuPengZTE/docker,mixja/docker,q384566678/docker,kolyshkin/docker,raja-sami-10p/moby,dccurtis/docker,yongtang/docker,bonczj/moby-json-file-logger,kencochrane/docker,shhsu/docker,madhanrm/docker,srust/docker,fcrisciani/docker,tianon/docker,duglin/docker,gschaetz/moby,xuxinkun/docker,naveed-jamil-tenpearls/moby,tophj-ibm/docker,AkihiroSuda/docker,laijs/moby,bearstech/moby,naveed-jamil-tenpearls/moby,cpuguy83/docker,miminar/docker,gjaskiewicz/moby,HideoYamauchi/docker,yummypeng/docker,mstanleyjones/docker,paralin/docker,moby/moby,nawawi/docker,coreos/docker,tophj-ibm/docker,jameszhan/docker,dims/docker,gschaetz/moby,ibuildthecloud/docker,HideoYamauchi/docker,crosbymichael/docker,POLJM242/docker,djs55/docker,paralin/docker,darrenstahlmsft/docker,whuwxl/docker,SvenDowideit/docker,jvanz/docker,PatrickLang/moby,alfred-landrum/docker,tophj-ibm/docker,ibuildthecloud/docker,nawawi/docker,qudongfang/docker,laijs/docker,cpuguy83/docker,konstruktoid/docker-upstream,tonistiigi/docker,gjaskiewicz/moby,jameszhan/docker,jlhawn/docker,estesp/docker,ffoysal/docker,yongtang/docker,prertik/docker,trebonian/docker,mixja/docker,jimjag/docker,allencloud/docker,rremer/moby,yosifkit/docker,liaoqingwei/docker,ffoysal/docker,gnailuy/docker,sdurrheimer/docker,ColinHebert/docker,moul/docker,moul/docker,charleszheng44/moby,moul/docker,moby/moby,konstruktoid/docker-1,erikh/docker,nalind/docker,KingEmet/docker,x1022as/docker,bearstech/moby,johnstep/moby-moby,catinthesky/docker,konstruktoid/docker-upstream,trebonian/docker,resin-io/docker,erikh/docker,nalind/docker,michael-holzheu/docker,PatrickLang/moby,jlhawn/docker,noironetworks/docker,kencochrane/docker,AkihiroSuda/docker,sarnautov/moby,justincormack/docker,dmcgowan/docker,cpuguy83/docker,docker/docker,yongtang/docker,mikedougherty/docker,flavio/docker,erikstmartin/docker,KarthikNayak/docker,resin-io/docker,justincormack/docker,xuxinkun/docker,hqhq/moby,gnailuy/docker,ibuildthecloud/docker,coolljt0725/docker,thaJeztah/docker,rhatdan/docker,KarthikNayak/docker,x1022as/docker,maxamillion/docker,hqhq/moby,trebonian/docker,unclejack/docker,trebonian/docker,imkin/moby,yosifkit/docker,dperny/docker,rremer/moby,jvanz/docker,mahak/docker,dsheets/moby,kojiromike/docker,madhanrm/docker,nawawi/docker,djs55/docker,mahak/docker,mikebrow/docker,imkin/moby,dmcgowan/docker,sterchelen/docker,paralin/docker,crosbymichael/docker,haveatry/docker,dsheets/moby,vdemeester/docker,shhsu/docker,sdurrheimer/docker,coolljt0725/docker,nawawi/docker,konstruktoid/docker-upstream,flavio/docker,raja-sami-10p/moby,scotttlin/docker,scotttlin/docker,diogomonica/docker,akira-baruah/docker,shishir-a412ed/docker