1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
naruse 2010-07-07 01:29:22 +00:00
parent 492d8e67d7
commit 8ff0574198
4 changed files with 80 additions and 1 deletions

View file

@ -1,3 +1,11 @@
Wed Jul 7 10:26:20 2010 NARUSE, Yui <naruse@ruby-lang.org>
* missing/close.c: ignore ECONNRESET.
FreeBSD wrongly sets ECONNRESET on close(2) and
it causes false-negative exceptions. [ruby-dev:41778]
* configure.in: ditto.
Tue Jul 6 22:57:21 2010 Tanaka Akira <akr@fsij.org>
* io.c (nogvl_copy_stream_sendfile): jump to retry_sendfile directly

View file

@ -926,6 +926,10 @@ main()
AC_DEFINE(BROKEN_SETREGID, 1)
ac_cv_sizeof_rlim_t=8],
[freebsd*], [ LIBS="-lm $LIBS"
ac_cv_func_getpeername=no
ac_cv_func_getsockname=no
ac_cv_func_shutdown=no
ac_cv_func_close=no
],
[dragonfly*], [ LIBS="-lm $LIBS"
],
@ -1119,6 +1123,7 @@ main()
rb_cv_broken_glibc_ia64_erfc=no)])
AS_CASE([$rb_cv_broken_glibc_ia64_erfc],[yes],[ac_cv_func_erf=no])
AS_CASE(["$target_os"],[freebsd],[],[AC_REPLACE_FUNCS(close)])
AC_REPLACE_FUNCS(dup2 memmove strerror\
strchr strstr crypt flock\
isnan finite isinf hypot acosh erf tgamma lgamma_r cbrt \
@ -1140,7 +1145,7 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot getcwd eacce
setitimer setruid seteuid setreuid setresuid setproctitle socketpair\
setrgid setegid setregid setresgid issetugid pause lchown lchmod\
getpgrp setpgrp getpgid setpgid initgroups getgroups setgroups\
getpriority getrlimit setrlimit sysconf \
getpriority getrlimit setrlimit sysconf close\
dlopen sigprocmask sigaction sigsetjmp _setjmp _longjmp\
setsid telldir seekdir fchmod cosh sinh tanh log2 round\
setuid setgid daemon select_large_fdset setenv unsetenv\

View file

@ -1421,6 +1421,17 @@ int ruby_vsnprintf(char *str, size_t n, char const *fmt, va_list ap);
#define snprintf ruby_snprintf
#define vsnprintf ruby_vsnprintf
#ifdef __FreeBSD__
#undef getpeername
#define getpeername ruby_getpeername
#undef getsockname
#define getsockname ruby_getsockname
#undef shutdown
#define shutdown ruby_shutdown
#undef close
#define close ruby_close
#endif
#if defined(__cplusplus)
#if 0
{ /* satisfy cc-mode */

55
missing/close.c Normal file
View file

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