2010-07-06 21:29:22 -04:00
|
|
|
/* 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)
|
|
|
|
{
|
2010-07-13 00:15:30 -04:00
|
|
|
int err = errno;
|
2010-07-06 21:29:22 -04:00
|
|
|
errno = 0;
|
|
|
|
s = getpeername(s, name, namelen);
|
|
|
|
if (errno == ECONNRESET) {
|
|
|
|
errno = 0;
|
|
|
|
s = 0;
|
|
|
|
}
|
2010-07-13 00:15:30 -04:00
|
|
|
else if (errno == 0)
|
|
|
|
errno = err;
|
2010-07-06 21:29:22 -04:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ruby_getsockname(int s, struct sockaddr * name,
|
|
|
|
socklen_t * namelen)
|
|
|
|
{
|
2010-07-13 00:15:30 -04:00
|
|
|
int err = errno;
|
2010-07-06 21:29:22 -04:00
|
|
|
errno = 0;
|
|
|
|
s = getsockname(s, name, namelen);
|
|
|
|
if (errno == ECONNRESET) {
|
|
|
|
errno = 0;
|
|
|
|
s = 0;
|
|
|
|
}
|
2010-07-13 00:15:30 -04:00
|
|
|
else if (errno == 0)
|
|
|
|
errno = err;
|
2010-07-06 21:29:22 -04:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ruby_shutdown(int s, int how)
|
|
|
|
{
|
2010-07-13 00:15:30 -04:00
|
|
|
int err = errno;
|
2010-07-06 21:29:22 -04:00
|
|
|
errno = 0;
|
|
|
|
s = shutdown(s, how);
|
|
|
|
if (errno == ECONNRESET) {
|
|
|
|
errno = 0;
|
|
|
|
s = 0;
|
|
|
|
}
|
2010-07-13 00:15:30 -04:00
|
|
|
else if (errno == 0)
|
|
|
|
errno = err;
|
2010-07-06 21:29:22 -04:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
ruby_close(int s)
|
|
|
|
{
|
2010-07-13 00:15:30 -04:00
|
|
|
int err = errno;
|
2010-07-06 21:29:22 -04:00
|
|
|
errno = 0;
|
|
|
|
s = close(s);
|
|
|
|
if (errno == ECONNRESET) {
|
|
|
|
errno = 0;
|
|
|
|
s = 0;
|
|
|
|
}
|
2010-07-13 00:15:30 -04:00
|
|
|
else if (errno == 0)
|
|
|
|
errno = err;
|
2010-07-06 21:29:22 -04:00
|
|
|
return s;
|
|
|
|
}
|