version 1.2.2.1, 2012/01/30 08:29:55
|
version 1.2.2.6, 2012/04/26 08:20:20
|
Line 85 cmdPINGREQ(void *srv, void *arg)
|
Line 85 cmdPINGREQ(void *srv, void *arg)
|
{ |
{ |
struct mqtthdr *hdr; |
struct mqtthdr *hdr; |
struct tagSession *sess = (struct tagSession*) arg; |
struct tagSession *sess = (struct tagSession*) arg; |
|
int siz = 0; |
|
|
ioTRACE(2); |
ioTRACE(2); |
|
|
Line 92 cmdPINGREQ(void *srv, void *arg)
|
Line 93 cmdPINGREQ(void *srv, void *arg)
|
return -1; |
return -1; |
|
|
hdr = (struct mqtthdr*) sess->sess_buf->msg_base; |
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; |
return 0; |
} |
} |
Line 107 cmdCONNECT(void *srv, void *arg)
|
Line 118 cmdCONNECT(void *srv, void *arg)
|
if (!sess) |
if (!sess) |
return -1; |
return -1; |
|
|
pthread_mutex_lock(&mtx_sess); | ioDEBUG(5, "Exec CONNECT session"); |
| SESS_LOCK; |
TAILQ_REMOVE(&Sessions, sess, sess_node); |
TAILQ_REMOVE(&Sessions, sess, sess_node); |
pthread_mutex_unlock(&mtx_sess); | SESS_UNLOCK; |
|
|
if (call.FiniSessPUB) |
if (call.FiniSessPUB) |
call.FiniSessPUB(&cfg, pub, sess->sess_cid, sess->sess_user, "%"); |
call.FiniSessPUB(&cfg, pub, sess->sess_cid, sess->sess_user, "%"); |
|
|
while ((store = TAILQ_FIRST(&sess->sess_sndqueue))) { | SESS_ELEM_LOCK(sess); |
TAILQ_REMOVE(&sess->sess_sndqueue, store, st_node); | while ((store = SLIST_FIRST(&sess->sess_subscr))) { |
| SLIST_REMOVE_HEAD(&sess->sess_subscr, st_node); |
|
|
if (store->st_subscr.sub_topic.msg_base) |
if (store->st_subscr.sub_topic.msg_base) |
free(store->st_subscr.sub_topic.msg_base); |
free(store->st_subscr.sub_topic.msg_base); |
Line 124 cmdCONNECT(void *srv, void *arg)
|
Line 137 cmdCONNECT(void *srv, void *arg)
|
|
|
free(store); |
free(store); |
} |
} |
|
SESS_ELEM_UNLOCK(sess); |
|
|
if (sess->sess_will.msg) |
if (sess->sess_will.msg) |
free(sess->sess_will.msg); |
free(sess->sess_will.msg); |
Line 145 cmdDISCONNECT(void *srv, void *arg)
|
Line 159 cmdDISCONNECT(void *srv, void *arg)
|
if (!sess) |
if (!sess) |
return -1; |
return -1; |
|
|
pthread_mutex_lock(&mtx_sess); | ioDEBUG(5, "Exec DISCONNECT session"); |
| SESS_LOCK; |
TAILQ_REMOVE(&Sessions, sess, sess_node); |
TAILQ_REMOVE(&Sessions, sess, sess_node); |
pthread_mutex_unlock(&mtx_sess); | SESS_UNLOCK; |
|
|
call.LOG(logg, "Session %s stopped from %s for user %s.\n", sess->sess_cid, |
call.LOG(logg, "Session %s stopped from %s for user %s.\n", sess->sess_cid, |
sess->sess_addr, sess->sess_user); |
sess->sess_addr, sess->sess_user); |