summaryrefslogtreecommitdiff
path: root/missing
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-07 01:29:22 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-07-07 01:29:22 +0000
commit8ff0574198d1d32c7f80044c611d54f6e3b1aace (patch)
tree7c5d7e5de49d2a69644bb83b61b5113f5661022b /missing
parent492d8e67d792fea29e48bbbec2b953c4e31c69b9 (diff)
* missing/close.c: ignore ECONNRESET.
FreeBSD wrongly sets ECONNRESET on close(2) and it causes false-negative exceptions. [ruby-dev:41778] * configure.in: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'missing')
-rw-r--r--missing/close.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/missing/close.c b/missing/close.c
new file mode 100644
index 0000000000..7e743eb204
--- /dev/null
+++ b/missing/close.c
@@ -0,0 +1,55 @@
+/* Ignore ECONNRESET of FreeBSD */
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int
+ruby_getpeername(int s, struct sockaddr * name,
+ socklen_t * namelen)
+{
+ errno = 0;
+ s = getpeername(s, name, namelen);
+ if (errno == ECONNRESET) {
+ errno = 0;
+ s = 0;
+ }
+ return s;
+}
+
+int
+ruby_getsockname(int s, struct sockaddr * name,
+ socklen_t * namelen)
+{
+ errno = 0;
+ s = getsockname(s, name, namelen);
+ if (errno == ECONNRESET) {
+ errno = 0;
+ s = 0;
+ }
+ return s;
+}
+
+int
+ruby_shutdown(int s, int how)
+{
+ errno = 0;
+ s = shutdown(s, how);
+ if (errno == ECONNRESET) {
+ errno = 0;
+ s = 0;
+ }
+ return s;
+}
+
+int
+ruby_close(int s)
+{
+ errno = 0;
+ s = close(s);
+ if (errno == ECONNRESET) {
+ errno = 0;
+ s = 0;
+ }
+ return s;
+}