Browse Source

... but if errno==EINVAL still fall back to socket+fcntl (Robert Henney)

master
Felix von Leitner 7 years ago
parent
commit
4ed2a16293
  1. 1
      CHANGES
  2. 9
      socket/socket_tcp4.c
  3. 8
      socket/socket_tcp6.c

1
CHANGES

@ -27,6 +27,7 @@
mmap_read/mmap_shared on zero length files no longer fail but return a
zero length buffer
if SOCK_NONBLOCK is defined, use it instead of socket+fcntl
... but if errno==EINVAL still fall back to socket+fcntl (Robert Henney)
0.29:
save 8 bytes in taia.h for 64-bit systems

9
socket/socket_tcp4.c

@ -6,14 +6,15 @@
#endif
#include "socket.h"
#include "ndelay.h"
#include <errno.h>
int socket_tcp4(void) {
int s;
#ifdef SOCK_NONBLOCK
return socket(PF_INET,SOCK_STREAM|SOCK_NONBLOCK,IPPROTO_TCP);
#else
int s=socket_tcp4b();
if ((s=socket(PF_INET,SOCK_STREAM|SOCK_NONBLOCK,IPPROTO_TCP))>-1 || errno!=EINVAL) return -1;
#endif
s=socket_tcp4b();
if (s==-1) return -1;
if (ndelay_on(s) == -1) { close(s); return -1; }
return s;
#endif
}

8
socket/socket_tcp6.c

@ -10,12 +10,12 @@
#include "ndelay.h"
int socket_tcp6(void) {
int s;
#if defined(LIBC_HAS_IP6) && defined(SOCK_NONBLOCK)
return socket(PF_INET6,SOCK_STREAM|SOCK_NONBLOCK,IPPROTO_TCP);
#else
int s=socket_tcp6b();
if ((s=socket(PF_INET6,SOCK_STREAM|SOCK_NONBLOCK,IPPROTO_TCP))>-1 || errno!=EINVAL) return -1;
#endif
s=socket_tcp6b();
if (s==-1) return -1;
if (ndelay_on(s) == -1) { close(s); return -1; }
return s;
#endif
}

Loading…
Cancel
Save