--- mqtt/src/mqttd.c 2012/05/05 14:51:02 1.2.2.7 +++ mqtt/src/mqttd.c 2012/06/01 11:39:15 1.2.2.9 @@ -9,7 +9,6 @@ io_enableDEBUG; cfg_root_t cfg; sessions_t Sessions; -pubs_t Pubs; sched_root_task_t *root; sqlite3 *acc, *pub; FILE *logg; @@ -68,7 +67,6 @@ main(int argc, char **argv) ait_val_t v; TAILQ_INIT(&Sessions); - TAILQ_INIT(&Pubs); strlcpy(szCfgName, DEFAULT_CONFIG, sizeof szCfgName); while ((ch = getopt(argc, argv, "hvbc:")) != -1) @@ -99,8 +97,9 @@ main(int argc, char **argv) for (i = 0; i < 3; i++) if (!mqttLoadRTLM(&cfg, i)) { printf("Error:: Can't load RTL module\n"); - while (i--) - mqttUnloadRTLM(i); + mqttUnloadRTLM(acc); + mqttUnloadRTLM(pub); + mqttUnloadRTLM(logg); cfgUnloadConfig(&cfg); closelog(); return 2; @@ -121,6 +120,7 @@ main(int argc, char **argv) goto end; } + if (mqttMkDir(&cfg)) { printf("Error:: in statedir #%d - %s\n", errno, strerror(errno)); ret = 3; @@ -192,9 +192,10 @@ end: /* free all resources */ call.CloseLOG(logg); call.ClosePUB(pub); call.CloseACC(acc); - for (i = 0; i < 3; i++) - mqttUnloadRTLM(i); - closelog(); + mqttUnloadRTLM(acc); + mqttUnloadRTLM(pub); + mqttUnloadRTLM(logg); cfgUnloadConfig(&cfg); + closelog(); return ret; }