Diff for /mqtt/src/mqttd.c between versions 1.2.2.1 and 1.2.2.6

version 1.2.2.1, 2012/04/11 15:08:27 version 1.2.2.6, 2012/04/24 13:54:50
Line 9  io_enableDEBUG; Line 9  io_enableDEBUG;
   
 cfg_root_t cfg;  cfg_root_t cfg;
 sessions_t Sessions;  sessions_t Sessions;
   pubs_t Pubs;
 sched_root_task_t *root;  sched_root_task_t *root;
 sqlite3 *acc, *pub;  sqlite3 *acc, *pub;
 pthread_mutex_t mtx_sess, mtx_pub;  pthread_mutex_t mtx_sess, mtx_pub;
 FILE *logg;  FILE *logg;
 extern char compiled[], compiledby[], compilehost[];  extern char compiled[], compiledby[], compilehost[];
 static char szCfgName[MAXPATHLEN];  static char szCfgName[MAXPATHLEN];
intptr_t Kill;volatile intptr_t Kill;
   
   
 static void  static void
Line 34  static void Line 35  static void
 sigHand(int sig)  sigHand(int sig)
 {  {
         int stat;          int stat;
           struct tagSession *sess;
   
         switch (sig) {          switch (sig) {
                 case SIGHUP:                  case SIGHUP:
Line 43  sigHand(int sig) Line 45  sigHand(int sig)
                                 break;                                  break;
                         }                          }
   
                        syslog(LOG_ERR, "Error:: can't reload #%d - %s", cfg_GetErrno(), cfg_GetError());                        ioLIBERR(cfg);
                 case SIGTERM:                  case SIGTERM:
                         ioDEBUG(1, "Terminate MQTT service in progress");                          ioDEBUG(1, "Terminate MQTT service in progress");
                         Kill++;                          Kill++;
   
                           SESS_LOCK;
                           TAILQ_FOREACH(sess, &Sessions, sess_node)
                                   if (sess->sess_tid)
                                           pthread_cancel(sess->sess_tid);
                           SESS_UNLOCK;
                         break;                          break;
                 case SIGCHLD:                  case SIGCHLD:
                         while (waitpid(-1, &stat, WNOHANG) > 0);                          while (waitpid(-1, &stat, WNOHANG) > 0);
Line 68  main(int argc, char **argv) Line 76  main(int argc, char **argv)
         ait_val_t v;          ait_val_t v;
   
         TAILQ_INIT(&Sessions);          TAILQ_INIT(&Sessions);
           TAILQ_INIT(&Pubs);
   
         strlcpy(szCfgName, DEFAULT_CONFIG, sizeof szCfgName);          strlcpy(szCfgName, DEFAULT_CONFIG, sizeof szCfgName);
         while ((ch = getopt(argc, argv, "hvbc:")) != -1)          while ((ch = getopt(argc, argv, "hvbc:")) != -1)
Line 155  main(int argc, char **argv) Line 164  main(int argc, char **argv)
                                 goto end;                                  goto end;
                 }                  }
         else          else
                ioVERBOSE(1) printf("Start service in batch mode ...\n");                ioDEBUG(1, "Start service in batch mode ...");
   
         memset(&sa, 0, sizeof sa);          memset(&sa, 0, sizeof sa);
         sigemptyset(&sa.sa_mask);          sigemptyset(&sa.sa_mask);
Line 164  main(int argc, char **argv) Line 173  main(int argc, char **argv)
         sigaction(SIGTERM, &sa, NULL);          sigaction(SIGTERM, &sa, NULL);
         sigaction(SIGCHLD, &sa, NULL);          sigaction(SIGCHLD, &sa, NULL);
         sigaction(SIGPIPE, &sa, NULL);          sigaction(SIGPIPE, &sa, NULL);
        ioDEBUG(2, "Service is ready for start engine ...");        ioDEBUG(2, "Service is ready for starting engine ...");
   
         if ((sock = srv_Socket(&cfg)) == -1) {          if ((sock = srv_Socket(&cfg)) == -1) {
                 ret = 4;                  ret = 4;
Line 181  main(int argc, char **argv) Line 190  main(int argc, char **argv)
         }          }
   
         if (!(root = schedBegin())) {          if (!(root = schedBegin())) {
                printf("Error:: scheduler #%d - %s\n", sched_GetErrno(), sched_GetError());                ioLIBERR(sched);
                 ret = 6;                  ret = 6;
                 goto end;                  goto end;
         }          }
   
           /* go catch the cat ... */
         Run(sock);          Run(sock);
   
         schedEnd(&root);          schedEnd(&root);
end:end:    /* free all resources */
         srv_Close(sock);          srv_Close(sock);
         call.CloseLOG(logg);          call.CloseLOG(logg);
         call.ClosePUB(pub);          call.ClosePUB(pub);

Removed from v.1.2.2.1  
changed lines
  Added in v.1.2.2.6


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>