version 1.2.2.6, 2012/04/11 16:37:17
|
version 1.2.2.8, 2012/04/15 23:45:34
|
Line 47 initSession(int sock, ait_val_t * __restrict v)
|
Line 47 initSession(int sock, ait_val_t * __restrict v)
|
return NULL; |
return NULL; |
} |
} |
|
|
|
/* init server actor */ |
sess->sess_srv = mqtt_srv_Init(sock, sess->sess_buf); |
sess->sess_srv = mqtt_srv_Init(sock, sess->sess_buf); |
if (!sess->sess_srv) { |
if (!sess->sess_srv) { |
ioDEBUG(3, "Error:: in srv_Init #%d - %s", mqtt_GetErrno(), mqtt_GetError()); |
ioDEBUG(3, "Error:: in srv_Init #%d - %s", mqtt_GetErrno(), mqtt_GetError()); |
Line 284 startSession(sched_task_t *task)
|
Line 285 startSession(sched_task_t *task)
|
assert(task); |
assert(task); |
|
|
if (!TASK_DATA(task)) { |
if (!TASK_DATA(task)) { |
|
/* flow from accept new clients */ |
sess = initSession(TASK_FD(task), TASK_ARG(task)); |
sess = initSession(TASK_FD(task), TASK_ARG(task)); |
if (!sess) { |
if (!sess) { |
io_freeVar(TASK_ARG(task)); |
io_freeVar(TASK_ARG(task)); |
Line 395 static void *
|
Line 397 static void *
|
thrSched(void *arg __unused) |
thrSched(void *arg __unused) |
{ |
{ |
struct tagSession *sess; |
struct tagSession *sess; |
struct timespec pl = { 0, 10000000 }; | struct timespec pl = { 0, 100000000 }; |
|
|
ioTRACE(1); |
ioTRACE(1); |
|
|
|
/* start scheduler loop */ |
schedPolling(root, &pl, NULL); |
schedPolling(root, &pl, NULL); |
schedRun(root, &Kill); |
schedRun(root, &Kill); |
|
|
Line 421 Run(int sock)
|
Line 424 Run(int sock)
|
|
|
ioTRACE(1); |
ioTRACE(1); |
|
|
|
/* start alternative thread for scheduler */ |
if (pthread_create(&tid, NULL, thrSched, NULL)) { |
if (pthread_create(&tid, NULL, thrSched, NULL)) { |
ioSYSERR(0); |
ioSYSERR(0); |
return -1; |
return -1; |
Line 433 Run(int sock)
|
Line 437 Run(int sock)
|
return -1; |
return -1; |
} |
} |
|
|
|
/* state machine - accept new connections */ |
while (!Kill) { |
while (!Kill) { |
if ((cli = accept(sock, &sa.sa, &sslen)) == -1) { |
if ((cli = accept(sock, &sa.sa, &sslen)) == -1) { |
if (!Kill) |
if (!Kill) |
Line 442 Run(int sock)
|
Line 447 Run(int sock)
|
} |
} |
v = io_allocVar(); |
v = io_allocVar(); |
if (!v) { |
if (!v) { |
ioLIBERR(mqtt); | ioLIBERR(io); |
break; |
break; |
} else { |
} else { |
memset(str, 0, sizeof str); |
memset(str, 0, sizeof str); |
snprintf(str, sizeof str, "%s:%hu", io_n2addr(&sa, v), io_n2port(&sa)); |
snprintf(str, sizeof str, "%s:%hu", io_n2addr(&sa, v), io_n2port(&sa)); |
|
AIT_FREE_VAL(v); |
AIT_SET_STR(v, str); |
AIT_SET_STR(v, str); |
} |
} |
ioDEBUG(1, "Connected client with socket=%d from %s", cli, AIT_GET_STR(v)); |
ioDEBUG(1, "Connected client with socket=%d from %s", cli, AIT_GET_STR(v)); |