solve problem of memory leak in closing client, pack client info with struct