blob: 831e75efe162075bec52f45349bc402e9ff101d2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/* Ignore ECONNRESET of FreeBSD */
#include "ruby/missing.h"
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#undef getpeername
int
ruby_getpeername(int s, struct sockaddr * name,
socklen_t * namelen)
{
int err = errno;
errno = 0;
s = getpeername(s, name, namelen);
if (errno == ECONNRESET) {
errno = 0;
s = 0;
}
else if (errno == 0)
errno = err;
return s;
}
#undef getsockname
int
ruby_getsockname(int s, struct sockaddr * name,
socklen_t * namelen)
{
int err = errno;
errno = 0;
s = getsockname(s, name, namelen);
if (errno == ECONNRESET) {
errno = 0;
s = 0;
}
else if (errno == 0)
errno = err;
return s;
}
#undef shutdown
int
ruby_shutdown(int s, int how)
{
int err = errno;
errno = 0;
s = shutdown(s, how);
if (errno == ECONNRESET) {
errno = 0;
s = 0;
}
else if (errno == 0)
errno = err;
return s;
}
#undef close
int
ruby_close(int s)
{
int err = errno;
errno = 0;
s = close(s);
if (errno == ECONNRESET) {
errno = 0;
s = 0;
}
else if (errno == 0)
errno = err;
return s;
}
|