version 1.2.2.23, 2012/05/05 12:15:25
|
version 1.2.2.24, 2012/05/05 13:39:27
|
Line 5
|
Line 5
|
#include "mqttd_calls.h" |
#include "mqttd_calls.h" |
|
|
|
|
static void *startSession(sched_task_t *task); |
|
static pthread_attr_t attr; |
|
|
|
|
|
static inline struct tagSession * |
static inline struct tagSession * |
initSession(int sock, ait_val_t * __restrict v) |
initSession(int sock, ait_val_t * __restrict v) |
{ |
{ |
Line 66 initSession(int sock, ait_val_t * __restrict v)
|
Line 62 initSession(int sock, ait_val_t * __restrict v)
|
return sess; |
return sess; |
} |
} |
|
|
static void | void |
finiSession(struct tagSession *sess) |
finiSession(struct tagSession *sess) |
{ |
{ |
struct tagStore *store; |
struct tagStore *store; |
Line 138 leaveClient(sched_task_t *task)
|
Line 134 leaveClient(sched_task_t *task)
|
static void * |
static void * |
dispatchSession(sched_task_t *task) |
dispatchSession(sched_task_t *task) |
{ |
{ |
int ret; | int ret, len = 0; |
struct mqtthdr *hdr; | |
struct tagSession *sess; |
struct tagSession *sess; |
|
|
ioTRACE(2); |
ioTRACE(2); |
Line 158 dispatchSession(sched_task_t *task)
|
Line 153 dispatchSession(sched_task_t *task)
|
ioDEBUG(4, "Session %s EOF received.", sess->sess_cid); |
ioDEBUG(4, "Session %s EOF received.", sess->sess_cid); |
finiSession(sess); |
finiSession(sess); |
return NULL; |
return NULL; |
} else | } |
hdr = (struct mqtthdr*) sess->sess_buf->msg_base; | |
|
|
/* dispatch message type */ | do { |
if (mqtt_srv_Dispatch(sess->sess_srv, sess)) | /* dispatch message type */ |
ioLIBERR(mqtt); | if ((len = mqtt_srv_Dispatch(sess->sess_srv, ret, sess)) == -1) { |
// schedEvent(root, startSession, NULL, (u_long) TASK_FD(task), sess, ret); | ioLIBERR(mqtt); |
| ret = 0; |
| } else |
| ret -= len; |
| } while (len && ret > 0); |
|
|
if (!schedRead(root, dispatchSession, TASK_ARG(task), TASK_FD(task), NULL, 0)) |
if (!schedRead(root, dispatchSession, TASK_ARG(task), TASK_FD(task), NULL, 0)) |
ioLIBERR(sched); |
ioLIBERR(sched); |
return NULL; |
return NULL; |
} |
} |
|
|
static void * | void * |
startSession(sched_task_t *task) |
startSession(sched_task_t *task) |
{ |
{ |
u_char basebuf[USHRT_MAX]; |
u_char basebuf[USHRT_MAX]; |
Line 344 Run(int sock)
|
Line 342 Run(int sock)
|
return -1; |
return -1; |
} |
} |
|
|
pthread_attr_init(&attr); |
|
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
|
|
|
schedPolling(root, &pl, NULL); |
schedPolling(root, &pl, NULL); |
schedRun(root, &Kill); |
schedRun(root, &Kill); |
|
|
pthread_attr_destroy(&attr); |
|
|
|
/* free all undeleted elements into lists */ |
/* free all undeleted elements into lists */ |
PUBS_LOCK; |
PUBS_LOCK; |