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

master
leitner 10 years ago
parent 35f5a9692a
commit 6e022f98c9

@ -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

@ -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
}

@ -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