BSD sockets fix-up
[akaros.git] / user / bsd / listen.c
index 4e977a4..f687446 100644 (file)
 
 #include "priv.h"
 
-extern int     _muxsid;
-extern void    _killmuxsid(void);
-
-/*
- * replace the fd with a pipe and start a process to
- * accept calls in.  this is all to make select work.
- */
-static int
-listenproc(Rock *r, int fd)
-{
-       Rock *nr;
-       char *net;
-       int cfd, nfd, dfd;
-       int pfd[2];
-       struct stat d;
-       char *p;
-       char listen[Ctlsize];
-       char name[Ctlsize];
-
-       switch(r->stype){
-       case SOCK_DGRAM:
-               net = "udp";
-               break;
-       case SOCK_STREAM:
-               net = "tcp";
-               break;
-       }
-
-       strcpy(listen, r->ctl);
-       p = strrchr(listen, '/');
-       if(p == 0)
-               return -1;
-       strcpy(p+1, "listen");
-
-       if(pipe(pfd) < 0)
-               return -1;
-
-       /* replace fd with a pipe */
-       nfd = dup(fd);
-       dup2(pfd[0], fd);
-       close(pfd[0]);
-       fstat(fd, &d);
-       r->inode = d.st_ino;
-       r->dev = d.st_dev;
-
-       /* start listening process */
-       switch(fork()){
-       case -1:
-               close(pfd[1]);
-               close(nfd);
-               return -1;
-       case 0:
-               if(_muxsid == -1) {
-                       fork(); //_RFORK(RFNOTEG);
-                       _muxsid = getpgrp();
-               } else
-                       setpgid(getpid(), _muxsid);
-               //_RENDEZVOUS(2, _muxsid);
-               break;
-       default:
-               atexit(_killmuxsid);
- #warning "no rendezvous for listen"
-               //_muxsid = _RENDEZVOUS(2, 0);
-               close(pfd[1]);
-               close(nfd);
-               return 0;
-       }
-
-/*     for(fd = 0; fd < 30; fd++)
-               if(fd != nfd && fd != pfd[1])
-                       close(fd);/**/
-
-       for(;;){
-               cfd = open(listen, O_RDWR);
-               if(cfd < 0)
-                       break;
-
-               dfd = _sock_data(cfd, net, r->domain, r->stype, r->protocol, &nr);
-               if(dfd < 0)
-                       break;
-
-               if(write(pfd[1], nr->ctl, strlen(nr->ctl)) < 0)
-                       break;
-               if(read(pfd[1], name, sizeof(name)) <= 0)
-                       break;
-
-               close(dfd);
-       }
-       exit(0);
-       return 0;
-}
-
 int
 listen(fd, backlog)
        int fd;
@@ -161,7 +69,8 @@ listen(fd, backlog)
                }
                close(cfd);
 
-               return listenproc(r, fd);
+               return 0;
+
        case PF_UNIX:
                if(r->other < 0){
                        errno = EINVAL;//EGREG;
@@ -169,7 +78,6 @@ listen(fd, backlog)
                }
                lunix = (struct sockaddr_un*)&r->addr;
                if(_sock_srv(lunix->sun_path, r->other) < 0){
-                       _syserrno();
                        r->other = -1;
                        return -1;
                }