Skip to content

Commit

Permalink
fixed cmsg parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto@sirius committed Mar 22, 2011
1 parent 425a45c commit 6aee788
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions protocol.c
Expand Up @@ -454,19 +454,20 @@ int uwsgi_parse_response(struct pollfd *upoll, int timeout, struct uwsgi_header

cmsg = CMSG_FIRSTHDR (&msg);
while(cmsg != NULL) {
if (cmsg->cmsg_len != CMSG_LEN (sizeof (int)) ||
cmsg->cmsg_level != SOL_SOCKET ||
cmsg->cmsg_type != SCM_RIGHTS) continue;
if (cmsg->cmsg_len == CMSG_LEN(sizeof(int)) &&
cmsg->cmsg_level == SOL_SOCKET &&
cmsg->cmsg_type && SCM_RIGHTS) {

// upgrade connection to the new socket
#ifdef UWSGI_DEBUG
uwsgi_log("upgrading fd %d to ", upoll->fd);
uwsgi_log("upgrading fd %d to ", upoll->fd);
#endif
close(upoll->fd);
memcpy(&upoll->fd, CMSG_DATA(cmsg), sizeof(int));
close(upoll->fd);
memcpy(&upoll->fd, CMSG_DATA(cmsg), sizeof(int));
#ifdef UWSGI_DEBUG
uwsgi_log("%d\n", upoll->fd);
uwsgi_log("%d\n", upoll->fd);
#endif
}
cmsg = CMSG_NXTHDR (&msg, cmsg);
}

Expand Down

0 comments on commit 6aee788

Please sign in to comment.