Allow socket() to accept SOCK_NONBLOCK (XCC)
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 20 Jul 2015 19:53:37 +0000 (15:53 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Fri, 24 Jul 2015 07:05:14 +0000 (03:05 -0400)
We're only supporting SOCK_NONBLOCK for the IP stack.

Rebuild glibc.

tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/socket.c

index e109365..f75fbc4 100644 (file)
 int __socket(int domain, int type, int protocol)
 {
        Rock *r;
-       int cfd, fd, n;
+       int cfd, n;
+       int open_flags = O_RDWR;
        int pfd[2];
        char *net;
        char msg[128];
 
        switch (domain) {
                case PF_INET:
+                       open_flags |= (type & SOCK_NONBLOCK ? O_NONBLOCK : 0);
                        /* get a free network directory */
                        switch (_sock_strip_opts(type)) {
                                case SOCK_DGRAM:
                                        net = "udp";
-                                       cfd = open("/net/udp/clone", O_RDWR);
+                                       cfd = open("/net/udp/clone", open_flags);
                                        /* All BSD UDP sockets are in 'headers' mode, where each packet has
                                         * the remote addr:port, local addr:port and other info. */
                                        if (!(cfd < 0)) {
@@ -54,7 +56,7 @@ int __socket(int domain, int type, int protocol)
                                        break;
                                case SOCK_STREAM:
                                        net = "tcp";
-                                       cfd = open("/net/tcp/clone", O_RDWR);
+                                       cfd = open("/net/tcp/clone", open_flags);
                                        break;
                                default:
                                        errno = EPROTONOSUPPORT;