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