ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-FDPass/FDPass.xs
(Generate patch)

Comparing IO-FDPass/FDPass.xs (file contents):
Revision 1.5 by root, Fri Apr 5 08:20:36 2013 UTC vs.
Revision 1.7 by root, Mon Jul 11 23:00:00 2016 UTC

32 #include <sys/types.h> 32 #include <sys/types.h>
33 #include <sys/uio.h> 33 #include <sys/uio.h>
34 #include <sys/socket.h> 34 #include <sys/socket.h>
35 35
36 #ifndef CMSG_SPACE 36 #ifndef CMSG_SPACE
37 # define CMSG_SPACE(len) (sizeof (cmsghdr) + len) 37 # define CMSG_SPACE(len) (sizeof (struct cmsghdr) + len)
38 #endif 38 #endif
39 39
40 #ifndef CMSG_LEN 40 #ifndef CMSG_LEN
41 # define CMSG_LEN(len) (sizeof (cmsghdr) + len) 41 # define CMSG_LEN(len) (sizeof (struct cmsghdr) + len)
42 #endif 42 #endif
43 43
44#endif 44#endif
45 45
46#if defined(WIN32) 46#if defined(WIN32)
192 192
193 if (recvmsg (socket, &msg, 0) <= 0) 193 if (recvmsg (socket, &msg, 0) <= 0)
194 return -1; 194 return -1;
195 195
196 int fd = -1; 196 int fd = -1;
197
198 errno = EDOM; 197 errno = EDOM;
199 198
200 if (
201 data == 0
202#if __OpenBSD__
203 && msg.msg_controllen >= CMSG_LEN (sizeof (int)) /* work around a bug in at least openbsd 4.5 and 4.8 */
204#else
205 && msg.msg_controllen >= CMSG_SPACE (sizeof (int))
206#endif
207 ) {
208 struct cmsghdr *cmsg = CMSG_FIRSTHDR (&msg); 199 struct cmsghdr *cmsg = CMSG_FIRSTHDR (&msg);
209 200
201 if (data == 0
202 && cmsg
210 if (cmsg->cmsg_level == SOL_SOCKET 203 && cmsg->cmsg_level == SOL_SOCKET
211 && cmsg->cmsg_type == SCM_RIGHTS 204 && cmsg->cmsg_type == SCM_RIGHTS
212 && cmsg->cmsg_len >= CMSG_LEN (sizeof (int))) 205 && cmsg->cmsg_len >= CMSG_LEN (sizeof (int)))
213 fd = *(int *)CMSG_DATA (cmsg); 206 fd = *(int *)CMSG_DATA (cmsg);
214 }
215 207
216 free (buf); 208 free (buf);
217 209
218 return fd; 210 return fd;
219#endif 211#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines