merges r28561 from trunk into ruby_1_9_2.

--
* 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/branches/ruby_1_9_2@28604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
yugui 2010-07-10 04:06:05 +00:00
parent aa1fdb9053
commit f813b7dc1a
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.
Sun Jul 4 17:13:14 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (swallow, prepare_getline_args, rb_io_getline_1): fix for

View file

@ -921,6 +921,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"
],
@ -1114,6 +1118,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 \
@ -1135,7 +1140,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;
}