[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.11 and 1.12

version 1.11, 2009/09/27 11:51:20 version 1.12, 2011/04/19 00:02:29
Line 18 
Line 18 
 #include <sys/socket.h>  #include <sys/socket.h>
 #include <sys/stat.h>  #include <sys/stat.h>
 #include <sys/un.h>  #include <sys/un.h>
   
 #include <err.h>  #include <err.h>
 #include <errno.h>  #include <errno.h>
 #include <fcntl.h>  #include <fcntl.h>
Line 45 
Line 44 
         listen_revents          listen_revents
 };  };
   
 struct listen *  void
 listen_new(struct fileops *ops, char *path)  listen_new_un(char *path)
 {  {
         int sock, oldumask;          int sock, oldumask;
         struct sockaddr_un sockname;          struct sockaddr_un sockname;
Line 55 
Line 54 
         sock = socket(AF_UNIX, SOCK_STREAM, 0);          sock = socket(AF_UNIX, SOCK_STREAM, 0);
         if (sock < 0) {          if (sock < 0) {
                 perror("socket");                  perror("socket");
                 return NULL;                  exit(1);
         }          }
         if (unlink(path) < 0 && errno != ENOENT) {          if (unlink(path) < 0 && errno != ENOENT) {
                 perror("unlink");                  perror("unlink");
Line 74 
Line 73 
                 perror("listen");                  perror("listen");
                 goto bad_close;                  goto bad_close;
         }          }
         f = (struct listen *)file_new(ops, path, 1);          f = (struct listen *)file_new(&listen_ops, path, 1);
         if (f == NULL)          if (f == NULL)
                 goto bad_close;                  goto bad_close;
         f->path = strdup(path);          f->path = strdup(path);
Line 83 
Line 82 
                 exit(1);                  exit(1);
         }          }
         f->fd = sock;          f->fd = sock;
         return f;          return;
  bad_close:   bad_close:
         close(sock);          close(sock);
         return NULL;          exit(1);
 }  }
   
 int  int
Line 116 
Line 115 
                 caddrlen = sizeof(caddrlen);                  caddrlen = sizeof(caddrlen);
                 sock = accept(f->fd, &caddr, &caddrlen);                  sock = accept(f->fd, &caddr, &caddrlen);
                 if (sock < 0) {                  if (sock < 0) {
                           /* XXX: should we kill the socket here ? */
                         perror("accept");                          perror("accept");
                         return 0;                          return 0;
                 }                  }
Line 137 
Line 137 
 {  {
         struct listen *f = (struct listen *)file;          struct listen *f = (struct listen *)file;
   
         unlink(f->path);          if (f->path != NULL) {
         free(f->path);                  unlink(f->path);
                   free(f->path);
           }
         close(f->fd);          close(f->fd);
   }
   
   void
   listen_closeall(void)
   {
           struct file *f, *fnext;
   
           for (f = LIST_FIRST(&file_list); f != NULL; f = fnext) {
                   fnext = LIST_NEXT(f, entry);
                   if (f->ops == &listen_ops)
                           file_close(f);
           }
 }  }

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12