--- mqtt/src/mqttd.c 2011/12/09 09:53:54 1.1.1.1.2.10 +++ mqtt/src/mqttd.c 2011/12/14 12:45:30 1.1.1.1.2.12 @@ -8,6 +8,9 @@ sl_config cfg; sessions_t Sessions; sched_root_task_t *root; +sqlite3 *acc, *pub; +pthread_mutex_t mtx_sess; +FILE *logg; extern char compiled[], compiledby[], compilehost[]; static char szCfgName[MAXPATHLEN]; int Verbose, Kill; @@ -55,8 +58,6 @@ main(int argc, char **argv) { char ch, batch = 0, szStr[STRSIZ]; register int i; - sqlite3 *acc = NULL, *pub = NULL; - FILE *logg = NULL; int sock = -1, ret = 0; struct passwd *pass; struct sigaction sa; @@ -87,6 +88,7 @@ main(int argc, char **argv) printf("Error:: can't load #%d - %s\n", cfg_GetErrno(), cfg_GetError()); return 1; } + pthread_mutex_init(&mtx_sess, NULL); openlog("mqttd", LOG_PID | LOG_CONS, LOG_DAEMON); for (i = 0; i < 3; i++) if (!mqttLoadRTLM(&cfg, i)) { @@ -95,6 +97,7 @@ main(int argc, char **argv) mqttUnloadRTLM(i); UnloadConfig(&cfg); closelog(); + pthread_mutex_destroy(&mtx_sess); return 2; } acc = call.OpenACC(&cfg); @@ -187,5 +190,6 @@ end: mqttUnloadRTLM(i); closelog(); UnloadConfig(&cfg); + pthread_mutex_destroy(&mtx_sess); return ret; }