Skip to content

Commit

Permalink
File descriptor passing code: set msg_controllen for better portability.
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarWidget committed May 6, 2008
1 parent db775b0 commit a5abd87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ext/apache2/MessageChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions ext/passenger/native_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a5abd87

Please sign in to comment.