Permalink
Browse files

File descriptor passing code: set msg_controllen for better portability.

  • Loading branch information...
FooBarWidget committed May 6, 2008
1 parent db775b0 commit a5abd879c20bfef2ae97c15ca349fec23ec2d857
Showing with 4 additions and 0 deletions.
  1. +2 −0 ext/apache2/MessageChannel.h
  2. +2 −0 ext/passenger/native_support.c
@@ -282,6 +282,8 @@ class MessageChannel {
control_header->cmsg_type = SCM_RIGHTS;
memcpy(CMSG_DATA(control_header), &fileDescriptor, sizeof(int));
+ msg.msg_controllen = control_header->cmsg_len;
+
if (sendmsg(fd, &msg, 0) == -1) {
throw SystemException("Cannot send file descriptor with sendmsg()", errno);
}
@@ -68,6 +68,8 @@ send_fd(VALUE self, VALUE socket_fd, VALUE fd_to_send) {
control_payload = NUM2INT(fd_to_send);
memcpy(CMSG_DATA(control_header), &control_payload, sizeof(int));
+ msg.msg_controllen = control_header->cmsg_len;
+
if (sendmsg(NUM2INT(socket_fd), &msg, 0) == -1) {
rb_sys_fail("sendmsg(2)");
return Qnil;

0 comments on commit a5abd87

Please sign in to comment.