Feature #9330 » 0003-socket-avoid-redundant-fcntl-calls-for-FD-passing.patch
ext/socket/ancdata.c | ||
---|---|---|
#include <time.h>
|
||
int rsock_cmsg_cloexec_state = -1; /* <0: unknown, 0: ignored, >0: working */
|
||
#if defined(HAVE_STRUCT_MSGHDR_MSG_CONTROL)
|
||
static VALUE rb_cAncillaryData;
|
||
... | ... | |
int *end = (int *)((char *)cmh + cmh->cmsg_len);
|
||
while ((char *)fdp + sizeof(int) <= (char *)end &&
|
||
(char *)fdp + sizeof(int) <= msg_end) {
|
||
rb_fd_fix_cloexec(*fdp);
|
||
rb_update_max_fd(*fdp);
|
||
close(*fdp);
|
||
fdp++;
|
||
}
|
||
... | ... | |
VALUE io;
|
||
if (fstat(fd, &stbuf) == -1)
|
||
rb_raise(rb_eSocket, "invalid fd in SCM_RIGHTS");
|
||
rb_fd_fix_cloexec(fd);
|
||
if (rsock_cmsg_cloexec_state < 0)
|
||
rsock_cmsg_cloexec_state = rsock_detect_cloexec(fd);
|
||
if (rsock_cmsg_cloexec_state == 0 || fd <= 2)
|
||
rb_maygvl_fd_fix_cloexec(fd);
|
||
if (S_ISSOCK(stbuf.st_mode))
|
||
io = rsock_init_sock(rb_obj_alloc(rb_cSocket), fd);
|
||
else
|
ext/socket/rubysocket.h | ||
---|---|---|
#define INET_SOCKS 2
|
||
extern int rsock_do_not_reverse_lookup;
|
||
extern int rsock_cmsg_cloexec_state;
|
||
#define FMODE_NOREVLOOKUP 0x100
|
||
extern VALUE rb_cBasicSocket;
|
ext/socket/unixsocket.c | ||
---|---|---|
#if FD_PASSING_BY_MSG_CONTROL
|
||
memcpy(&fd, CMSG_DATA(&cmsg.hdr), sizeof(int));
|
||
#endif
|
||
rb_fd_fix_cloexec(fd);
|
||
if (klass == Qnil)
|
||
if (rsock_cmsg_cloexec_state < 0)
|
||
rsock_cmsg_cloexec_state = rsock_detect_cloexec(fd);
|
||
if (rsock_cmsg_cloexec_state == 0 || fd <= 2)
|
||
rb_maygvl_fd_fix_cloexec(fd);
|
||
if (klass == Qnil) {
|
||
rb_update_max_fd(fd);
|
||
return INT2FIX(fd);
|
||
}
|
||
else {
|
||
ID for_fd;
|
||
int ff_argc;
|
- « Previous
- 1
- 2
- 3
- Next »