diff options
-rw-r--r-- | src/nxt_clang.h | 2 | ||||
-rw-r--r-- | src/nxt_port.h | 4 | ||||
-rw-r--r-- | src/nxt_socketpair.c | 8 |
3 files changed, 12 insertions, 2 deletions
diff --git a/src/nxt_clang.h b/src/nxt_clang.h index b69dd6af..65bd7940 100644 --- a/src/nxt_clang.h +++ b/src/nxt_clang.h @@ -230,4 +230,6 @@ nxt_trunc_ptr(p, a) \ (u_char *) ((uintptr_t) (p) & ~((uintptr_t) (a) - 1)) +#define NXT_PACKED __attribute__((packed)) + #endif /* _NXT_CLANG_H_INCLUDED_ */ diff --git a/src/nxt_port.h b/src/nxt_port.h index 927e0e2e..109071aa 100644 --- a/src/nxt_port.h +++ b/src/nxt_port.h @@ -30,7 +30,7 @@ typedef struct { /* Message data send using mmap, next chunk is a nxt_port_mmap_msg_t. */ uint8_t mmap; /* 1 bit */ -} nxt_port_msg_t; +} NXT_PACKED nxt_port_msg_t; typedef struct { @@ -91,7 +91,7 @@ typedef struct { size_t max_size; size_t max_share; nxt_process_type_t type:8; -} nxt_port_msg_new_port_t; +} NXT_PACKED nxt_port_msg_new_port_t; /* diff --git a/src/nxt_socketpair.c b/src/nxt_socketpair.c index e1c303dd..efa0f486 100644 --- a/src/nxt_socketpair.c +++ b/src/nxt_socketpair.c @@ -188,6 +188,10 @@ nxt_sendmsg(nxt_socket_t s, nxt_fd_t fd, nxt_iobuf_t *iob, nxt_uint_t niob) msg.msg_control = (caddr_t) &cmsg; msg.msg_controllen = sizeof(cmsg); +#if (NXT_VALGRIND) + nxt_memzero(&cmsg, sizeof(cmsg)); +#endif + cmsg.cm.cmsg_len = CMSG_LEN(sizeof(int)); cmsg.cm.cmsg_level = SOL_SOCKET; cmsg.cm.cmsg_type = SCM_RIGHTS; @@ -231,6 +235,10 @@ nxt_recvmsg(nxt_socket_t s, nxt_fd_t *fd, nxt_iobuf_t *iob, nxt_uint_t niob) *fd = -1; +#if (NXT_VALGRIND) + nxt_memzero(&cmsg, sizeof(cmsg)); +#endif + n = recvmsg(s, &msg, 0); if (n > 0 |