Diff for /mqtt/src/daemon.c between versions 1.1.2.3 and 1.1.2.4

version 1.1.2.3, 2011/12/01 00:10:18 version 1.1.2.4, 2011/12/01 08:15:25
Line 1 Line 1
 #include "global.h"  #include "global.h"
   
   
   static int
   startSession(int s, const char *csAddr)
   {
           return 0;
   }
   
   /* ----------------------------------------------------------------------- */
   
 int  int
 Run(int sock)  Run(int sock)
 {  {
           io_sockaddr_t sa;
           socklen_t sslen = sizeof sa.ss;
           int cli;
           char szAddr[STRSIZ] = { 0 };
   
         FTRACE(1);          FTRACE(1);
   
         if (listen(sock, SOMAXCONN) == -1) {          if (listen(sock, SOMAXCONN) == -1) {
                syslog(LOG_ERR, "Error:: listen() #%d - %s\n", errno, strerror(errno));                syslog(LOG_ERR, "Error:: listen(%d) #%d - %s\n", sock, errno, strerror(errno));
                 return -1;                  return -1;
           }
   
           while (!Kill) {
                   if ((cli = accept(sock, &sa.sa, &sslen)) == -1) {
                           syslog(LOG_ERR, "Error:: accept() #%d - %s", errno, strerror(errno));
                           continue;
                   } else
                           VERB(1) {
                                   switch (sa.sa.sa_family) {
                                           case AF_INET:
                                                   inet_ntop(AF_INET, &sa.sin.sin_addr, szAddr, sslen);
                                                   snprintf(szAddr, sizeof szAddr, "%s:%d", 
                                                                   szAddr, ntohs(sa.sin.sin_port));
                                                   break;
                                           case AF_INET6:
                                                   inet_ntop(AF_INET6, &sa.sin6.sin6_addr, szAddr, sslen);
                                                   snprintf(szAddr, sizeof szAddr, "%s:%d", 
                                                                   szAddr, ntohs(sa.sin6.sin6_port));
                                                   break;
                                           case AF_LOCAL:
                                                   strlcpy(szAddr, sa.sun.sun_path, sizeof szAddr);
                                                   break;
                                           default:
                                                   close(cli);
                                                   syslog(LOG_ERR, "Error:: unsupported address type %d", 
                                                                   sa.sa.sa_family);
                                                   continue;
                                   }
                                   syslog(LOG_DEBUG, "Connected client with socket=%d from %s", cli, szAddr);
                           }
   
                   if (startSession(cli, szAddr)) {
                           close(cli);
                           VERB(1) syslog(LOG_DEBUG, "Terminated client with socket=%d", cli);
                           continue;
                   }
         }          }
   
         return 0;          return 0;

Removed from v.1.1.2.3  
changed lines
  Added in v.1.1.2.4


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