[BACK]Return to listen.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / aucat

Diff for /src/usr.bin/aucat/Attic/listen.c between version 1.16 and 1.17

version 1.16, 2011/05/03 08:00:54 version 1.17, 2011/10/12 07:20:04
Line 36 
Line 36 
 #include "conf.h"  #include "conf.h"
 #include "listen.h"  #include "listen.h"
 #include "sock.h"  #include "sock.h"
   #include "dbg.h"
   
 struct fileops listen_ops = {  struct fileops listen_ops = {
         "listen",          "listen",
Line 50 
Line 51 
         listen_revents          listen_revents
 };  };
   
   struct listen *listen_list = NULL;
   
 void  void
 listen_new_un(char *path)  listen_new_un(char *path)
 {  {
Line 75 
Line 78 
                 goto bad_close;                  goto bad_close;
         }          }
         umask(oldumask);          umask(oldumask);
         if (listen(sock, 1) < 0) {  
                 perror("listen");  
                 goto bad_close;  
         }  
         f = (struct listen *)file_new(&listen_ops, path, 1);          f = (struct listen *)file_new(&listen_ops, path, 1);
         if (f == NULL)          if (f == NULL)
                 goto bad_close;                  goto bad_close;
Line 88 
Line 87 
                 exit(1);                  exit(1);
         }          }
         f->fd = sock;          f->fd = sock;
           f->next = listen_list;
           listen_list = f;
         return;          return;
  bad_close:   bad_close:
         close(sock);          close(sock);
Line 136 
Line 137 
                         perror("bind");                          perror("bind");
                         goto bad_close;                          goto bad_close;
                 }                  }
                 if (listen(s, 1) < 0) {  
                         perror("listen");  
                         goto bad_close;  
                 }  
                 f = (struct listen *)file_new(&listen_ops, addr, 1);                  f = (struct listen *)file_new(&listen_ops, addr, 1);
                 if (f == NULL) {                  if (f == NULL) {
                 bad_close:                  bad_close:
Line 148 
Line 145 
                 }                  }
                 f->path = NULL;                  f->path = NULL;
                 f->fd = s;                  f->fd = s;
                   f->next = listen_list;
                   listen_list = f;
                 n++;                  n++;
         }          }
         freeaddrinfo(ailist);          freeaddrinfo(ailist);
Line 156 
Line 155 
 }  }
   
 int  int
   listen_init(struct listen *f)
   {
           if (listen(f->fd, 1) < 0) {
                   perror("listen");
                   return 0;
           }
           return 1;
   }
   
   int
 listen_nfds(struct file *f) {  listen_nfds(struct file *f) {
         return 1;          return 1;
 }  }
Line 211 
Line 220 
 void  void
 listen_close(struct file *file)  listen_close(struct file *file)
 {  {
         struct listen *f = (struct listen *)file;          struct listen *f = (struct listen *)file, **pf;
   
         if (f->path != NULL) {          if (f->path != NULL) {
                 unlink(f->path);                  unlink(f->path);
                 free(f->path);                  free(f->path);
         }          }
         close(f->fd);          close(f->fd);
 }          for (pf = &listen_list; *pf != f; pf = &(*pf)->next) {
   #ifdef DEBUG
 void                  if (*pf == NULL) {
 listen_closeall(void)                          dbg_puts("listen_close: not on list\n");
 {                          dbg_panic();
         struct file *f, *fnext;                  }
   #endif
         for (f = LIST_FIRST(&file_list); f != NULL; f = fnext) {  
                 fnext = LIST_NEXT(f, entry);  
                 if (f->ops == &listen_ops)  
                         file_close(f);  
         }          }
           *pf = f->next;
 }  }

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17