Make the router data structures remove duplicates cleanly
Make the router data structures remove duplicates cleanly

The bug is caused by the modification of the route.  In the code it
would add a new object to the list of routes by the host and not
remove them.  When the route was deleted, it would remove all of the
routes with the same name, and then the list would be cleared.
Unfortunately, the code would then look at the number of items in the
list, and either delete it from the map, or clean items out of the
list.  But since it was possible for there to be multiple duplicate
names, we could end up with an empty list.  Later code would assume
that if there was a key in the map, then the associated list would
have items.  That caused a panic.

This fix changes both places:
- If there are duplicates, remove them all, and then if the list is
  empty, delete the key from the map
- When a modification happens, remove the previous entry from the list

So, the first duplicate check is now just for protection, but the
proper fix is to clean out the lists before adding items to them.

Fixes bug 1371826

dcbw/origin,gabemontero/origin,jupierce/origin,juanvallejo/origin,csrwng/origin,xiuwang/origin,enj/origin,inlandsee/origin,deads2k/origin,chlunde/origin,liangxia/origin,abutcher/origin,luciddreamz/origin,php-coder/origin,dmage/origin,pravisankar/origin,rhamilto/origin,mdshuai/origin,maxamillion/origin,bparees/origin,goern/origin,gabemontero/origin,ironcladlou/origin,hferentschik/origin,inlandsee/origin,sspeiche/origin,childsb/origin,mfojtik/origin,Miciah/origin,ramr/origin,kargakis/origin,ryanj/origin,dgoodwin/origin,simo5/origin,anpingli/origin,abutcher/origin,dcbw/origin,simo5/origin,rootfs/origin,jsafrane/origin,coreydaley/origin,legionus/origin,enj/origin,jprukner/origin,dobbymoodge/origin,sjug/origin,jeffvance/origin,maxamillion/origin,spadgett/origin,luciddreamz/origin,rrati/origin,jwhonce/origin,sg00dwin/origin,wanghaoran1988/origin,mkumatag/origin,mdshuai/origin,pecameron/origin,nak3/origin,smarterclayton/origin,legionus/origin,nak3/origin,elyscape/origin,raffaelespazzoli/origin,matthyx/origin,thrasher-redhat/origin,sallyom/origin,smarterclayton/origin,zhaosijun/origin,hroyrh/origin,elyscape/origin,miminar/origin,adelton/origin,xiuwang/origin,rootfs/origin,wanghaoran1988/origin,miminar/origin,markllama/origin,louyihua/origin,ryanj/origin,thrasher-redhat/origin,mrogers950/origin,marun/origin,dcbw/origin,markllama/origin,mkumatag/origin,dgoodwin/origin,rhamilto/origin,php-coder/origin,jupierce/origin,hferentschik/origin,rrati/origin,sferich888/origin,dobbymoodge/origin,dinhxuanvu/origin,thrasher-redhat/origin,nak3/origin,detiber/origin,stevekuznetsov/origin,kargakis/origin,jpeeler/origin,abutcher/origin,linzhaoming/origin,rrati/origin,sjug/origin,rootfs/origin,robertol/origin,robertol/origin,sferich888/origin,JacobTanenbaum/origin,rajatchopra/origin,jeffvance/origin,dinhxuanvu/origin,adelton/origin,jprukner/origin,jsafrane/origin,markllama/origin,rajatchopra/origin,kargakis/origin,aveshagarwal/origin,raffaelespazzoli/origin,inlandsee/origin,chmouel/origin,ramr/origin,goern/origin,rhcarvalho/origin,detiber/origin,simo5/origin,legionus/origin,linzhaoming/origin,rhcarvalho/origin,rajatchopra/origin,abutcher/origin,php-coder/origin,pweil-/origin,legionus/origin,sspeiche/origin,smarterclayton/origin,pweil-/origin,danmcp/origin,rootfs/origin,ingvagabund/origin,ryanj/origin,mdshuai/origin,abutcher/origin,arilivigni/origin,jim-minter/origin,JacobTanenbaum/origin,liggitt/origin,tnozicka/origin,php-coder/origin,ravisantoshgudimetla/origin,pweil-/origin,chlunde/origin,kargakis/origin,chmouel/origin,jeremyeder/origin,liggitt/origin,smarterclayton/origin,dobbymoodge/origin,php-coder/origin,jprukner/origin,aveshagarwal/origin,maleck13/origin,wanghaoran1988/origin,mrogers950/origin,mrogers950/origin,zhaosijun/origin,liggitt/origin,rrati/origin,jprukner/origin,anpingli/origin,nhr/origin,rhcarvalho/origin,maxamillion/origin,jwhonce/origin,nhr/origin,liangxia/origin,linzhaoming/origin,jeremyeder/origin,wjiangjay/origin,nhr/origin,matthyx/origin,xiuwang/origin,robertol/origin,ravisantoshgudimetla/origin,anpingli/origin,stevekuznetsov/origin,ramr/origin,sjug/origin,luciddreamz/origin,jpeeler/origin,akram/origin,php-coder/origin,pmorie/origin,PI-Victor/origin,juanvallejo/origin,coreydaley/origin,dinhxuanvu/origin,jeffvance/origin,adelton/origin,rajatchopra/origin,marun/origin,childsb/origin,louyihua/origin,maxamillion/origin,imcsk8/origin,detiber/origin,jpeeler/origin,pmorie/origin,mahak/origin,aveshagarwal/origin,jwhonce/origin,wanghaoran1988/origin,tnozicka/origin,sspeiche/origin,dinhxuanvu/origin,tnozicka/origin,rhamilto/origin,sg00dwin/origin,smarterclayton/origin,ironcladlou/origin,jwhonce/origin,kargakis/origin,csrwng/origin,jpeeler/origin,pecameron/origin,liggitt/origin,jeremyeder/origin,maleck13/origin,luciddreamz/origin,sg00dwin/origin,imcsk8/origin,openshift/origin,dcbw/origin,coreydaley/origin,wjiangjay/origin,spadgett/origin,detiber/origin,robertol/origin,jprukner/origin,jupierce/origin,rajatchopra/origin,rhcarvalho/origin,wjiangjay/origin,liggitt/origin,rootfs/origin,csrwng/origin,mahak/origin,akram/origin,spadgett/origin,goern/origin,deads2k/origin,tdawson/origin,simo5/origin,juanvallejo/origin,sdminonne/origin,dobbymoodge/origin,hroyrh/origin,mfojtik/origin,soltysh/origin,ingvagabund/origin,miminar/origin,ncdc/origin,pmorie/origin,ravisantoshgudimetla/origin,zhaosijun/origin,spadgett/origin,pmorie/origin,sg00dwin/origin,marun/origin,gabemontero/origin,nhr/origin,hferentschik/origin,pravisankar/origin,sferich888/origin,chlunde/origin,tnozicka/origin,pecameron/origin,dmage/origin,wjiangjay/origin,maleck13/origin,dcbw/origin,thrasher-redhat/origin,jprukner/origin,mrogers950/origin,kargakis/origin,dgoodwin/origin,rajatchopra/origin,PI-Victor/origin,jeremyeder/origin,mdshuai/origin,jeremyeder/origin,aveshagarwal/origin,louyihua/origin,tdawson/origin,dmage/origin,stevekuznetsov/origin,openshift/origin,childsb/origin,raffaelespazzoli/origin,liggitt/origin,spadgett/origin,mahak/origin,chmouel/origin,mdshuai/origin,maxamillion/origin,PI-Victor/origin,elyscape/origin,jupierce/origin,dobbymoodge/origin,rhamilto/origin,hferentschik/origin,wjiangjay/origin,rhamilto/origin,miminar/origin,arilivigni/origin,imcsk8/origin,arilivigni/origin,goern/origin,louyihua/origin,ravisantoshgudimetla/origin,danmcp/origin,simo5/origin,raffaelespazzoli/origin,childsb/origin,louyihua/origin,rrati/origin,dinhxuanvu/origin,markllama/origin,mfojtik/origin,legionus/origin,dgoodwin/origin,eparis/origin,jim-minter/origin,tdawson/origin,openshift/origin,juanvallejo/origin,inlandsee/origin,danmcp/origin,PI-Victor/origin,sdminonne/origin,luciddreamz/origin,ironcladlou/origin,eparis/origin,dobbymoodge/origin,pravisankar/origin,jpeeler/origin,ryanj/origin,elyscape/origin,sdminonne/origin,pmorie/origin,imcsk8/origin,tnozicka/origin,tdawson/origin,linzhaoming/origin,ryanj/origin,ramr/origin,ramr/origin,bparees/origin,matthyx/origin,deads2k/origin,jim-minter/origin,PI-Victor/origin,dgoodwin/origin,aveshagarwal/origin,mrogers950/origin,hferentschik/origin,PI-Victor/origin,liangxia/origin,zhaosijun/origin,childsb/origin,markllama/origin,adelton/origin,imcsk8/origin,jsafrane/origin,Miciah/origin,stevekuznetsov/origin,eparis/origin,adelton/origin,liangxia/origin,sallyom/origin,arilivigni/origin,robertol/origin,enj/origin,liangxia/origin,elyscape/origin,juanvallejo/origin,dmage/origin,pravisankar/origin,soltysh/origin,nhr/origin,liangxia/origin,ingvagabund/origin,sallyom/origin,rhcarvalho/origin,jupierce/origin,maleck13/origin,miminar/origin,matthyx/origin,linzhaoming/origin,ravisantoshgudimetla/origin,soltysh/origin,JacobTanenbaum/origin,akram/origin,ncdc/origin,wjiangjay/origin,matthyx/origin,sspeiche/origin,chlunde/origin,marun/origin,mrogers950/origin,childsb/origin,luciddreamz/origin,danmcp/origin,Miciah/origin,chmouel/origin,jwhonce/origin,robertol/origin,markllama/origin,pravisankar/origin,juanvallejo/origin,eparis/origin,mdshuai/origin,wanghaoran1988/origin,ryanj/origin,ncdc/origin,mkumatag/origin,ncdc/origin,bparees/origin,detiber/origin,hroyrh/origin,tnozicka/origin,miminar/origin,imcsk8/origin,jeffvance/origin,jwhonce/origin,hferentschik/origin