public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Search Repo:
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Attempt to fix file descriptor passing (again).
Hongli Lai (Phusion) (author)
Wed Apr 30 14:01:47 -0700 2008
commit  52cf0c496435270dbc3a34ebdd50243d93d8448c
tree    88c8a4177b9aaeb6c062416b42d13695774450b4
parent  af4a8e13209f31dfd59914261266a4427a1942c6
...
262
263
264
265
266
267
268
...
282
283
284
285
286
 
287
288
289
...
443
444
445
446
 
447
448
449
...
262
263
264
 
265
266
267
...
281
282
283
 
 
284
285
286
287
...
441
442
443
 
444
445
446
447
0
@@ -262,7 +262,6 @@
0
     char dummy[1];
0
     char control_data[CMSG_SPACE(sizeof(int))];
0
     struct cmsghdr *control_header;
0
- int *control_payload;
0
   
0
     msg.msg_name = NULL;
0
     msg.msg_namelen = 0;
0
@@ -282,8 +281,7 @@
0
     control_header->cmsg_len = CMSG_LEN(sizeof(int));
0
     control_header->cmsg_level = SOL_SOCKET;
0
     control_header->cmsg_type = SCM_RIGHTS;
0
- control_payload = (int *) CMSG_DATA(CMSG_FIRSTHDR(&msg));
0
- *control_payload = fileDescriptor;
0
+ memcpy(CMSG_DATA(control_header), &fileDescriptor, sizeof(int));
0
     
0
     if (sendmsg(fd, &msg, 0) == -1) {
0
       throw SystemException("Cannot send file descriptor with sendmsg()", errno);
0
@@ -443,7 +441,7 @@
0
     msg.msg_flags = 0;
0
     
0
     if (recvmsg(fd, &msg, 0) == -1) {
0
- throw SystemException("Cannot read file descriptor with recvmsg()", errno);
0
+ throw SystemException("Cannot rCMSG_DATA(control_header)ead file descriptor with recvmsg()", errno);
0
     }
0
     
0
     control_header = CMSG_FIRSTHDR(&msg);
...
46
47
48
49
 
50
51
52
...
66
67
68
69
70
 
 
71
72
73
...
46
47
48
 
49
50
51
52
...
66
67
68
 
 
69
70
71
72
73
0
@@ -46,7 +46,7 @@
0
   char dummy[1];
0
   char control_data[CMSG_SPACE(sizeof(int))];
0
   struct cmsghdr *control_header;
0
- int *control_payload;
0
+ int control_payload;
0
   
0
   msg.msg_name = NULL;
0
   msg.msg_namelen = 0;
0
@@ -66,8 +66,8 @@
0
   control_header->cmsg_len = CMSG_LEN(sizeof(int));
0
   control_header->cmsg_level = SOL_SOCKET;
0
   control_header->cmsg_type = SCM_RIGHTS;
0
- control_payload = (int *) CMSG_DATA(CMSG_FIRSTHDR(&msg));
0
- *control_payload = NUM2INT(fd_to_send);
0
+ control_payload = NUM2INT(fd_to_send);
0
+ memcpy(CMSG_DATA(control_header), &control_payload, sizeof(int));
0
   
0
   if (sendmsg(NUM2INT(socket_fd), &msg, 0) == -1) {
0
     rb_sys_fail("sendmsg(2)");

Comments

    No one has commented yet.