14 char buff[max_message_size];
16 struct msghdr msg = {};
20 std::vector<wrapped_fd> fds;
24 .iov_len =
sizeof(buff)
27 char buf[CMSG_SPACE(max_num_fds *
sizeof(
int))];
33 msg.msg_control = u.buf;
34 msg.msg_controllen =
sizeof(u.buf);
38 red = recvmsg(fd, &msg, 0);
39 }
while(red == -1 && errno == EINTR);
40 if(red < 1 ||
static_cast<unsigned>(red) >=
sizeof(buff))
41 return {
false, message, std::move(fds)};
48 return {
false, message, std::move(fds)};
51 if(msg.msg_controllen) {
52 cmsg = CMSG_FIRSTHDR(&msg);
53 unsigned num_of_fds = (cmsg->cmsg_len - CMSG_LEN(0))/
sizeof(
int);
54 if(num_of_fds > max_num_fds)
55 return {
false, message, std::move(fds)};
56 int* fd_ptr = (
int*)CMSG_DATA(cmsg);
57 for(
unsigned i = 0; i < num_of_fds; ++i)
58 fds.push_back(*fd_ptr++);
61 return {
true, message, std::move(fds)};
69 struct msghdr msg = {};
73 if(sz > max_message_size)
75 char buff[max_message_size];
84 if(fds.size() > max_num_fds)
92 char buf[CMSG_SPACE(max_num_fds *
sizeof(
int))];
99 msg.msg_control = u.buf;
100 msg.msg_controllen =
sizeof(u.buf);
101 cmsg = CMSG_FIRSTHDR(&msg);
102 cmsg->cmsg_level = SOL_SOCKET;
103 cmsg->cmsg_type = SCM_RIGHTS;
104 cmsg->cmsg_len = CMSG_LEN(
sizeof(
int) * fds.size());
105 unsigned char*
p = CMSG_DATA(cmsg);
108 memcpy(
p, &thisfd,
sizeof(thisfd));
115 wrote = sendmsg(fd_to_send_to, &msg, 0);
116 }
while(wrote == -1 && errno == EINTR);
std::variant< initialize_message, initalize_response_message, compile_wasm_message, evict_wasms_message, code_compilation_result_message, wasm_compilation_result_message > eosvmoc_message