rpc: Discard non-blocking calls only when necessary
rpc: Discard non-blocking calls only when necessary

Currently, non-blocking calls are either sent immediately or discarded
in case sending would block. This was implemented based on the
assumption that the non-blocking keepalive call is not needed as there
are other calls in the queue which would keep the connection alive.
However, if those calls are no-reply calls (such as those carrying
stream data), the remote party knows the connection is alive but since
we don't get any reply from it, we think the connection is dead.

This is most visible in tunnelled migration. If it happens to be longer
than keepalive timeout (30s by default), it may be unexpectedly aborted
because the connection is considered to be dead.

With this patch, we only discard non-blocking calls when the last call
with a thread is completed and thus there is no thread left to keep
sending the remaining non-blocking calls.

jfehlig/libvirt,taget/libvirt,dumbbell/libvirt,andreabolognani/libvirt,emaste/libvirt,rmarwaha/libvirt1,nertpinx/libvirt,bjzhang/libvirt,andreabolognani/libvirt,fabianfreyer/libvirt,rlaager/libvirt,dumbbell/libvirt,trainstack/libvirt,agx/libvirt,agx/libvirt,fabianfreyer/libvirt,jardasgit/libvirt,warewolf/libvirt,andreabolognani/libvirt,libvirt/libvirt,shugaoye/libvirt,rlaager/libvirt,trainstack/libvirt,emaste/libvirt,jfehlig/libvirt,olafhering/libvirt,rmarwaha/libvirt,agx/libvirt,bjzhang/libvirt,emaste/libvirt,agx/libvirt,emaste/libvirt,novel/fbsd-libvirt,iam-TJ/libvirt,VenkatDatta/libvirt,taget/libvirt,taget/libvirt,cbosdo/libvirt,siboulet/libvirt-openvz,cbosdo/libvirt,nertpinx/libvirt,iam-TJ/libvirt,zippy2/libvirt,andreabolognani/libvirt,siboulet/libvirt-openvz,rmarwaha/libvirt1,elmarco/libvirt,iam-TJ/libvirt,bjzhang/libvirt,jeckersb/libvirt,novel/fbsd-libvirt,libvirt/libvirt,dumbbell/libvirt,emaste/libvirt,jeckersb/libvirt,jeckersb/libvirt,elmarco/libvirt,zhlcindy/libvirt-1.1.4-maintain,rmarwaha/libvirt,emaste/libvirt,agx/libvirt,jeckersb/libvirt,VenkatDatta/libvirt,dumbbell/libvirt,cbosdo/libvirt,libvirt/libvirt,warewolf/libvirt,jeckersb/libvirt,fabianfreyer/libvirt,trainstack/libvirt,rmarwaha/libvirt1,fabianfreyer/libvirt,wiedi/libvirt,shugaoye/libvirt,zippy2/libvirt,wiedi/libvirt,wiedi/libvirt,siboulet/libvirt-openvz,eskultety/libvirt,novel/fbsd-libvirt,datto/libvirt,zippy2/libvirt,elmarco/libvirt,rmarwaha/libvirt,libvirt/libvirt,rmarwaha/libvirt,trainstack/libvirt,jardasgit/libvirt,jfehlig/libvirt,bjzhang/libvirt,trainstack/libvirt,dumbbell/libvirt,trainstack/libvirt,eskultety/libvirt,crobinso/libvirt,novel/fbsd-libvirt,wiedi/libvirt,novel/fbsd-libvirt,warewolf/libvirt,datto/libvirt,zhlcindy/libvirt-1.1.4-maintain,jfehlig/libvirt,elmarco/libvirt,warewolf/libvirt,wiedi/libvirt,rmarwaha/libvirt,datto/libvirt,nertpinx/libvirt,zhlcindy/libvirt-1.1.4-maintain,shugaoye/libvirt,eskultety/libvirt,zhlcindy/libvirt-1.1.4-maintain,olafhering/libvirt,dumbbell/libvirt,cbosdo/libvirt,nertpinx/libvirt,rmarwaha/libvirt1,crobinso/libvirt,iam-TJ/libvirt,warewolf/libvirt,VenkatDatta/libvirt,olafhering/libvirt,wiedi/libvirt,iam-TJ/libvirt,iam-TJ/libvirt,rlaager/libvirt,jardasgit/libvirt,fabianfreyer/libvirt,elmarco/libvirt,eskultety/libvirt,jardasgit/libvirt,novel/fbsd-libvirt,novel/fbsd-libvirt,siboulet/libvirt-openvz,datto/libvirt,taget/libvirt,shugaoye/libvirt,zippy2/libvirt,zhlcindy/libvirt-1.1.4-maintain,cbosdo/libvirt,nertpinx/libvirt,crobinso/libvirt,taget/libvirt,eskultety/libvirt,rmarwaha/libvirt,bjzhang/libvirt,shugaoye/libvirt,olafhering/libvirt,crobinso/libvirt,novel/fbsd-libvirt,VenkatDatta/libvirt,andreabolognani/libvirt,jeckersb/libvirt,rmarwaha/libvirt1,datto/libvirt,siboulet/libvirt-openvz,emaste/libvirt,rlaager/libvirt,warewolf/libvirt,wiedi/libvirt,rmarwaha/libvirt1,jardasgit/libvirt,trainstack/libvirt,jeckersb/libvirt,iam-TJ/libvirt,warewolf/libvirt,novel/fbsd-libvirt,rlaager/libvirt,VenkatDatta/libvirt