--- mqtt/src/mqttd_calls.c 2012/01/30 08:29:55 1.2.2.1 +++ mqtt/src/mqttd_calls.c 2012/01/30 13:39:22 1.2.2.2 @@ -85,6 +85,7 @@ cmdPINGREQ(void *srv, void *arg) { struct mqtthdr *hdr; struct tagSession *sess = (struct tagSession*) arg; + int siz = 0; ioTRACE(2); @@ -92,6 +93,16 @@ cmdPINGREQ(void *srv, void *arg) return -1; hdr = (struct mqtthdr*) sess->sess_buf->msg_base; + siz = mqtt_msgPINGRESP(sess->sess_buf); + if (siz == -1) { + ioDEBUG(5, "Error:: in msgPINGRESP #%d - %s", mqtt_GetErrno(), mqtt_GetError()); + return 0; + } + if ((siz = send(sess->sess_sock, sess->sess_buf->msg_base, siz, 0)) == -1) { + ioSYSERR(0); + return 0; + } else + ioDEBUG(5, "Sended %d bytes.", siz); return 0; } @@ -114,6 +125,7 @@ cmdCONNECT(void *srv, void *arg) if (call.FiniSessPUB) call.FiniSessPUB(&cfg, pub, sess->sess_cid, sess->sess_user, "%"); + pthread_mutex_lock(&sess->sess_mtx); while ((store = TAILQ_FIRST(&sess->sess_sndqueue))) { TAILQ_REMOVE(&sess->sess_sndqueue, store, st_node); @@ -124,6 +136,7 @@ cmdCONNECT(void *srv, void *arg) free(store); } + pthread_mutex_unlock(&sess->sess_mtx); if (sess->sess_will.msg) free(sess->sess_will.msg);