--- mqtt/src/mqttd.c 2011/12/14 15:09:31 1.1.1.1.2.13 +++ mqtt/src/mqttd.c 2012/01/24 10:18:45 1.1.1.1.2.15 @@ -11,7 +11,7 @@ sl_config cfg; sessions_t Sessions; sched_root_task_t *root; sqlite3 *acc, *pub; -pthread_mutex_t mtx_sess; +pthread_mutex_t mtx_sess, mtx_pub; FILE *logg; extern char compiled[], compiledby[], compilehost[]; static char szCfgName[MAXPATHLEN]; @@ -51,6 +51,8 @@ sigHand(int sig) case SIGCHLD: while (waitpid(-1, &stat, WNOHANG) > 0); break; + case SIGPIPE: + break; } } @@ -91,6 +93,7 @@ main(int argc, char **argv) return 1; } pthread_mutex_init(&mtx_sess, NULL); + pthread_mutex_init(&mtx_pub, NULL); openlog("mqttd", LOG_PID | LOG_CONS, LOG_DAEMON); for (i = 0; i < 3; i++) if (!mqttLoadRTLM(&cfg, i)) { @@ -99,6 +102,7 @@ main(int argc, char **argv) mqttUnloadRTLM(i); UnloadConfig(&cfg); closelog(); + pthread_mutex_destroy(&mtx_pub); pthread_mutex_destroy(&mtx_sess); return 2; } @@ -157,6 +161,7 @@ main(int argc, char **argv) sigaction(SIGHUP, &sa, NULL); sigaction(SIGTERM, &sa, NULL); sigaction(SIGCHLD, &sa, NULL); + sigaction(SIGPIPE, &sa, NULL); ioDEBUG(2, "Service is ready for start engine ..."); if ((sock = srv_Socket(&cfg)) == -1) { @@ -190,6 +195,7 @@ end: mqttUnloadRTLM(i); closelog(); UnloadConfig(&cfg); + pthread_mutex_destroy(&mtx_pub); pthread_mutex_destroy(&mtx_sess); return ret; }