|
8 | 8 |
|
9 | 9 | #include "multiprocessing.h"
|
10 | 10 |
|
11 |
| -#ifdef SCM_RIGHTS |
12 |
| - #define HAVE_FD_TRANSFER 1 |
13 |
| -#else |
14 |
| - #define HAVE_FD_TRANSFER 0 |
15 |
| -#endif |
16 | 11 |
|
17 | 12 | PyObject *create_win32_namespace(void);
|
18 | 13 |
|
@@ -75,115 +70,7 @@ ProcessingCtrlHandler(DWORD dwCtrlType)
|
75 | 70 | return FALSE;
|
76 | 71 | }
|
77 | 72 |
|
78 |
| -/* |
79 |
| - * Unix only |
80 |
| - */ |
81 |
| - |
82 |
| -#else /* !MS_WINDOWS */ |
83 |
| - |
84 |
| -#if HAVE_FD_TRANSFER |
85 |
| - |
86 |
| -/* Functions for transferring file descriptors between processes. |
87 |
| - Reimplements some of the functionality of the fdcred |
88 |
| - module at http://www.mca-ltd.com/resources/fdcred_1.tgz. */ |
89 |
| -/* Based in http://resin.csoft.net/cgi-bin/man.cgi?section=3&topic=CMSG_DATA */ |
90 |
| - |
91 |
| -static PyObject * |
92 |
| -multiprocessing_sendfd(PyObject *self, PyObject *args) |
93 |
| -{ |
94 |
| - int conn, fd, res; |
95 |
| - struct iovec dummy_iov; |
96 |
| - char dummy_char; |
97 |
| - struct msghdr msg; |
98 |
| - struct cmsghdr *cmsg; |
99 |
| - union { |
100 |
| - struct cmsghdr hdr; |
101 |
| - unsigned char buf[CMSG_SPACE(sizeof(int))]; |
102 |
| - } cmsgbuf; |
103 |
| - |
104 |
| - if (!PyArg_ParseTuple(args, "ii", &conn, &fd)) |
105 |
| - return NULL; |
106 |
| - |
107 |
| - dummy_iov.iov_base = &dummy_char; |
108 |
| - dummy_iov.iov_len = 1; |
109 |
| - |
110 |
| - memset(&msg, 0, sizeof(msg)); |
111 |
| - msg.msg_control = &cmsgbuf.buf; |
112 |
| - msg.msg_controllen = sizeof(cmsgbuf.buf); |
113 |
| - msg.msg_iov = &dummy_iov; |
114 |
| - msg.msg_iovlen = 1; |
115 |
| - |
116 |
| - cmsg = CMSG_FIRSTHDR(&msg); |
117 |
| - cmsg->cmsg_len = CMSG_LEN(sizeof(int)); |
118 |
| - cmsg->cmsg_level = SOL_SOCKET; |
119 |
| - cmsg->cmsg_type = SCM_RIGHTS; |
120 |
| - * (int *) CMSG_DATA(cmsg) = fd; |
121 |
| - |
122 |
| - Py_BEGIN_ALLOW_THREADS |
123 |
| - res = sendmsg(conn, &msg, 0); |
124 |
| - Py_END_ALLOW_THREADS |
125 |
| - |
126 |
| - if (res < 0) |
127 |
| - return PyErr_SetFromErrno(PyExc_OSError); |
128 |
| - Py_RETURN_NONE; |
129 |
| -} |
130 |
| - |
131 |
| -static PyObject * |
132 |
| -multiprocessing_recvfd(PyObject *self, PyObject *args) |
133 |
| -{ |
134 |
| - int conn, fd, res; |
135 |
| - char dummy_char; |
136 |
| - struct iovec dummy_iov; |
137 |
| - struct msghdr msg = {0}; |
138 |
| - struct cmsghdr *cmsg; |
139 |
| - union { |
140 |
| - struct cmsghdr hdr; |
141 |
| - unsigned char buf[CMSG_SPACE(sizeof(int))]; |
142 |
| - } cmsgbuf; |
143 |
| - |
144 |
| - if (!PyArg_ParseTuple(args, "i", &conn)) |
145 |
| - return NULL; |
146 |
| - |
147 |
| - dummy_iov.iov_base = &dummy_char; |
148 |
| - dummy_iov.iov_len = 1; |
149 |
| - |
150 |
| - memset(&msg, 0, sizeof(msg)); |
151 |
| - msg.msg_control = &cmsgbuf.buf; |
152 |
| - msg.msg_controllen = sizeof(cmsgbuf.buf); |
153 |
| - msg.msg_iov = &dummy_iov; |
154 |
| - msg.msg_iovlen = 1; |
155 |
| - |
156 |
| - cmsg = CMSG_FIRSTHDR(&msg); |
157 |
| - cmsg->cmsg_level = SOL_SOCKET; |
158 |
| - cmsg->cmsg_type = SCM_RIGHTS; |
159 |
| - cmsg->cmsg_len = CMSG_LEN(sizeof(int)); |
160 |
| - msg.msg_controllen = cmsg->cmsg_len; |
161 |
| - |
162 |
| - Py_BEGIN_ALLOW_THREADS |
163 |
| - res = recvmsg(conn, &msg, 0); |
164 |
| - Py_END_ALLOW_THREADS |
165 |
| - |
166 |
| - if (res < 0) |
167 |
| - return PyErr_SetFromErrno(PyExc_OSError); |
168 |
| - |
169 |
| - if (msg.msg_controllen < CMSG_LEN(sizeof(int)) || |
170 |
| - (cmsg = CMSG_FIRSTHDR(&msg)) == NULL || |
171 |
| - cmsg->cmsg_level != SOL_SOCKET || |
172 |
| - cmsg->cmsg_type != SCM_RIGHTS || |
173 |
| - cmsg->cmsg_len < CMSG_LEN(sizeof(int))) { |
174 |
| - /* If at least one control message is present, there should be |
175 |
| - no room for any further data in the buffer. */ |
176 |
| - PyErr_SetString(PyExc_RuntimeError, "No file descriptor received"); |
177 |
| - return NULL; |
178 |
| - } |
179 |
| - |
180 |
| - fd = * (int *) CMSG_DATA(cmsg); |
181 |
| - return Py_BuildValue("i", fd); |
182 |
| -} |
183 |
| - |
184 |
| -#endif /* HAVE_FD_TRANSFER */ |
185 |
| - |
186 |
| -#endif /* !MS_WINDOWS */ |
| 73 | +#endif /* MS_WINDOWS */ |
187 | 74 |
|
188 | 75 |
|
189 | 76 | /*
|
@@ -212,16 +99,6 @@ static PyMethodDef module_methods[] = {
|
212 | 99 | {"address_of_buffer", multiprocessing_address_of_buffer, METH_O,
|
213 | 100 | "address_of_buffer(obj) -> int\n"
|
214 | 101 | "Return address of obj assuming obj supports buffer inteface"},
|
215 |
| -#if HAVE_FD_TRANSFER |
216 |
| - {"sendfd", multiprocessing_sendfd, METH_VARARGS, |
217 |
| - "sendfd(sockfd, fd) -> None\n" |
218 |
| - "Send file descriptor given by fd over the unix domain socket\n" |
219 |
| - "whose file decriptor is sockfd"}, |
220 |
| - {"recvfd", multiprocessing_recvfd, METH_VARARGS, |
221 |
| - "recvfd(sockfd) -> fd\n" |
222 |
| - "Receive a file descriptor over a unix domain socket\n" |
223 |
| - "whose file decriptor is sockfd"}, |
224 |
| -#endif |
225 | 102 | {NULL}
|
226 | 103 | };
|
227 | 104 |
|
@@ -319,9 +196,6 @@ PyInit__multiprocessing(void)
|
319 | 196 | #ifdef HAVE_SEM_TIMEDWAIT
|
320 | 197 | ADD_FLAG(HAVE_SEM_TIMEDWAIT);
|
321 | 198 | #endif
|
322 |
| -#ifdef HAVE_FD_TRANSFER |
323 |
| - ADD_FLAG(HAVE_FD_TRANSFER); |
324 |
| -#endif |
325 | 199 | #ifdef HAVE_BROKEN_SEM_GETVALUE
|
326 | 200 | ADD_FLAG(HAVE_BROKEN_SEM_GETVALUE);
|
327 | 201 | #endif
|
|
0 commit comments