Make changes to the bsd library to get it to built with netperf.
authorRonald G. Minnich <rminnich@google.com>
Sat, 26 Apr 2014 01:23:27 +0000 (18:23 -0700)
committerRonald G. Minnich <rminnich@google.com>
Sat, 26 Apr 2014 01:23:27 +0000 (18:23 -0700)
More needs doing. I'm going to remove any use of select from netperf.

Signed-off-by: Ronald G. Minnich <rminnich@google.com>
Makefile
user/bsd/_sock_srv.c
user/bsd/accept.c
user/bsd/connect.c
user/bsd/gethostbyname.c
user/bsd/getprotobyname.c
user/bsd/getservbyname.c
user/bsd/listen.c
user/bsd/socket.c

index 4322e0b..b159817 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -536,7 +536,7 @@ endif #ifeq ($(mixed-targets),1)
 # List all userspace directories here, and state any dependencies between them,
 # such as how pthread depends on parlib.
 
-user-dirs = parlib pthread benchutil iplib ndblib 
+user-dirs = parlib pthread benchutil iplib ndblib bsd
 pthread: parlib benchutil
 iplib: parlib
 ndblib: iplib
index 2acd025..cd1f617 100644 (file)
@@ -53,12 +53,10 @@ _sock_srv(char *path, int fd)
        sfd = creat(msg, 0666);
        if(sfd < 0){
                close(fd);
-               _syserrno();
                return -1;
        }
        snprintf(msg, sizeof msg, "%d", fd);
        if(write(sfd, msg, strlen(msg)) < 0){
-               _syserrno();
                close(sfd);
                close(fd);
                return -1;
index fbf3c01..adbcea8 100644 (file)
@@ -56,25 +56,21 @@ accept(int fd, __SOCKADDR_ARG __addr,
                /* get control file name from listener process */
                n = read(fd, name, sizeof(name)-1);
                if(n <= 0){
-                       _syserrno();
                        return -1;
                }
                name[n] = 0;
                cfd = open(name, O_RDWR);
                if(cfd < 0){
-                       _syserrno();
                        return -1;
                }
 
                nfd = _sock_data(cfd, net, r->domain, r->stype, r->protocol, &nr);
                if(nfd < 0){
-                       _syserrno();
                        return -1;
                }
 
                if(write(fd, "OK", 2) < 0){
                        close(nfd);
-                       _syserrno();
                        return -1;
                }
 
index 8b67821..2696e00 100644 (file)
@@ -49,7 +49,6 @@ int connect (int fd, __CONST_SOCKADDR_ARG a, socklen_t alen)
                /* set up a tcp or udp connection */
                cfd = open(r->ctl, O_RDWR);
                if(cfd < 0){
-                       _syserrno();
                        return -1;
                }
                /* whatever .. */
@@ -66,7 +65,6 @@ int connect (int fd, __CONST_SOCKADDR_ARG a, socklen_t alen)
                                r->reserved ? "!r" : "");
                n = write(cfd, msg, strlen(msg));
                if(n < 0){
-                       _syserrno();
                        close(cfd);
                        return -1;
                }
@@ -96,12 +94,10 @@ int connect (int fd, __CONST_SOCKADDR_ARG a, socklen_t alen)
                _sock_srvname(file, runix->sun_path);
                nfd = open(file, O_RDWR);
                if(nfd < 0){
-                       _syserrno();
                        unlink(msg);
                        return -1;
                }
                if(write(nfd, msg, strlen(msg)) < 0){
-                       _syserrno();
                        close(nfd);
                        unlink(msg);
                        return -1;
index 17ce051..273bd45 100644 (file)
@@ -53,7 +53,6 @@ gethostbyname(const char *name)
        /* connect to server */
        fd = open("/net/cs", O_RDWR);
        if(fd < 0){
-               _syserrno();
                h_errno = NO_RECOVERY;
                return 0;
        }
@@ -73,7 +72,6 @@ gethostbyname(const char *name)
 
        /* query the server */
        if(write(fd, buf, strlen(buf)) < 0){
-               _syserrno();
                h_errno = TRY_AGAIN;
                return 0;
        }
index 1241031..c208458 100644 (file)
@@ -43,7 +43,6 @@ struct protoent *getprotobyname(const char *name) {
        /* connect to server */
        fd = open("/net/cs", O_RDWR);
        if(fd < 0){
-               _syserrno();
                h_errno = NO_RECOVERY;
                return 0;
        }
@@ -53,7 +52,6 @@ struct protoent *getprotobyname(const char *name) {
 
        /* query the server */
        if(write(fd, buf, strlen(buf)) < 0){
-               _syserrno();
                h_errno = TRY_AGAIN;
                return 0;
        }
index 069e57b..6525486 100644 (file)
@@ -53,7 +53,6 @@ getservbyname(const char *name, const char *proto)
        /* connect to server */
        fd = open("/net/cs", O_RDWR);
        if(fd < 0){
-               _syserrno();
                return 0;
        }
 
@@ -65,7 +64,6 @@ getservbyname(const char *name, const char *proto)
 
        /* query the server */
        if(write(fd, buf, strlen(buf)) < 0){
-               _syserrno();
                return 0;
        }
        lseek(fd, 0, 0);
index 4e977a4..4483602 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.
+ * NO LONGER A PROC ON AKAROS.
  */
 static int
 listenproc(Rock *r, int fd)
@@ -38,7 +36,6 @@ listenproc(Rock *r, int fd)
        Rock *nr;
        char *net;
        int cfd, nfd, dfd;
-       int pfd[2];
        struct stat d;
        char *p;
        char listen[Ctlsize];
@@ -59,62 +56,17 @@ listenproc(Rock *r, int fd)
                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;
+                       return -1;
 
                dfd = _sock_data(cfd, net, r->domain, r->stype, r->protocol, &nr);
                if(dfd < 0)
-                       break;
+                       return -1;
 
-               if(write(pfd[1], nr->ctl, strlen(nr->ctl)) < 0)
-                       break;
-               if(read(pfd[1], name, sizeof(name)) <= 0)
-                       break;
+               return fd;
 
-               close(dfd);
-       }
-       exit(0);
-       return 0;
 }
 
 int
@@ -161,7 +113,7 @@ listen(fd, backlog)
                }
                close(cfd);
 
-               return listenproc(r, fd);
+               return fd;
        case PF_UNIX:
                if(r->other < 0){
                        errno = EINVAL;//EGREG;
@@ -169,7 +121,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;
                }
index 36d025d..a60cc08 100644 (file)
@@ -139,13 +139,11 @@ socket(int domain, int stype, int protocol)
                        return -1;
                }
                if(cfd < 0){
-                       _syserrno();
                        return -1;
                }
                return _sock_data(cfd, net, domain, stype, protocol, 0);
        case PF_UNIX:
                if(pipe(pfd) < 0){
-                       _syserrno();
                        return -1;
                }
                r = _sock_newrock(pfd[0]);