Fix infinite loop in bulk sync
Fix infinite loop in bulk sync

Due to a slice management logic error the bulk sync for loop can go on
indefinitely and eventually leading to an OOM error. Fixed the logic so
that an infinite loop never occurs. Also changed the bulk sync wait
timeout to use a timer rather than use time.After as time.After is known
to consume a lot of memory when called in a tight loop.

Signed-off-by: Jana Radhakrishnan <045898bda7d4800fe4909a9831e702ab79e266be@docker.com>

vdemeester/libnetwork,vdemeester/libnetwork,kolyshkin/libnetwork,abhi/libnetwork,coolljt0725/libnetwork,fcrisciani/libnetwork,medallia/libnetwork,mahak/libnetwork,docker/libnetwork,mavenugo/libnetwork,mbanikazemi/libnetwork,mahak/libnetwork,medallia/libnetwork,YujiOshima/libnetwork,abhi/libnetwork,ityangchen/libnetwork,vdemeester/libnetwork,tmakita/libnetwork,msabansal/libnetwork,mYmNeo/libnetwork,kolyshkin/libnetwork,msabansal/libnetwork,docker/libnetwork,allencloud/libnetwork,abhi/libnetwork,kolyshkin/libnetwork,allencloud/libnetwork,medallia/libnetwork,mahak/libnetwork,mbanikazemi/libnetwork,docker/libnetwork,fcrisciani/libnetwork,curtiszimmerman/libnetwork,coolljt0725/libnetwork,cpuguy83/libnetwork,WeiZhang555/libnetwork,YujiOshima/libnetwork,mavenugo/libnetwork,sainath14/libnetwork,curtiszimmerman/libnetwork,tmakita/libnetwork,mYmNeo/libnetwork,sainath14/libnetwork,cpuguy83/libnetwork,ityangchen/libnetwork,WeiZhang555/libnetwork