* missing/close.c: keep original errno.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2010-07-13 04:15:30 +00:00
Родитель 6d7ee07a93
Коммит 29b4247ca1
2 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -1,3 +1,7 @@
Tue Jul 13 12:04:57 2010 NARUSE, Yui <naruse@ruby-lang.org>
* missing/close.c: keep original errno.
Mon Jul 12 01:58:56 2010 Marc-Andre Lafortune <ruby-core@marc-andre.ca> Mon Jul 12 01:58:56 2010 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
* lib/csv.rb: Fix unused variable warnings. * lib/csv.rb: Fix unused variable warnings.

Просмотреть файл

@ -8,12 +8,15 @@ int
ruby_getpeername(int s, struct sockaddr * name, ruby_getpeername(int s, struct sockaddr * name,
socklen_t * namelen) socklen_t * namelen)
{ {
int err = errno;
errno = 0; errno = 0;
s = getpeername(s, name, namelen); s = getpeername(s, name, namelen);
if (errno == ECONNRESET) { if (errno == ECONNRESET) {
errno = 0; errno = 0;
s = 0; s = 0;
} }
else if (errno == 0)
errno = err;
return s; return s;
} }
@ -21,35 +24,44 @@ int
ruby_getsockname(int s, struct sockaddr * name, ruby_getsockname(int s, struct sockaddr * name,
socklen_t * namelen) socklen_t * namelen)
{ {
int err = errno;
errno = 0; errno = 0;
s = getsockname(s, name, namelen); s = getsockname(s, name, namelen);
if (errno == ECONNRESET) { if (errno == ECONNRESET) {
errno = 0; errno = 0;
s = 0; s = 0;
} }
else if (errno == 0)
errno = err;
return s; return s;
} }
int int
ruby_shutdown(int s, int how) ruby_shutdown(int s, int how)
{ {
int err = errno;
errno = 0; errno = 0;
s = shutdown(s, how); s = shutdown(s, how);
if (errno == ECONNRESET) { if (errno == ECONNRESET) {
errno = 0; errno = 0;
s = 0; s = 0;
} }
else if (errno == 0)
errno = err;
return s; return s;
} }
int int
ruby_close(int s) ruby_close(int s)
{ {
int err = errno;
errno = 0; errno = 0;
s = close(s); s = close(s);
if (errno == ECONNRESET) { if (errno == ECONNRESET) {
errno = 0; errno = 0;
s = 0; s = 0;
} }
else if (errno == 0)
errno = err;
return s; return s;
} }