Fixbug: serv->onClose=null will throw segment fault