qmsg_svr.c: fix bugs and make server robust upon disconnection.