diff options
author | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-16 18:49:26 +0900 |
---|---|---|
committer | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-30 00:39:06 +0900 |
commit | fcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch) | |
tree | 64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/missing/close.c |
Fresh start
Diffstat (limited to 'jni/ruby/missing/close.c')
-rw-r--r-- | jni/ruby/missing/close.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/jni/ruby/missing/close.c b/jni/ruby/missing/close.c new file mode 100644 index 0000000..831e75e --- /dev/null +++ b/jni/ruby/missing/close.c @@ -0,0 +1,72 @@ +/* Ignore ECONNRESET of FreeBSD */ +#include "ruby/missing.h" +#include <errno.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/socket.h> + +#undef getpeername +int +ruby_getpeername(int s, struct sockaddr * name, + socklen_t * namelen) +{ + int err = errno; + errno = 0; + s = getpeername(s, name, namelen); + if (errno == ECONNRESET) { + errno = 0; + s = 0; + } + else if (errno == 0) + errno = err; + return s; +} + +#undef getsockname +int +ruby_getsockname(int s, struct sockaddr * name, + socklen_t * namelen) +{ + int err = errno; + errno = 0; + s = getsockname(s, name, namelen); + if (errno == ECONNRESET) { + errno = 0; + s = 0; + } + else if (errno == 0) + errno = err; + return s; +} + +#undef shutdown +int +ruby_shutdown(int s, int how) +{ + int err = errno; + errno = 0; + s = shutdown(s, how); + if (errno == ECONNRESET) { + errno = 0; + s = 0; + } + else if (errno == 0) + errno = err; + return s; +} + +#undef close +int +ruby_close(int s) +{ + int err = errno; + errno = 0; + s = close(s); + if (errno == ECONNRESET) { + errno = 0; + s = 0; + } + else if (errno == 0) + errno = err; + return s; +} |