Obsolete
/
libipc-old
Archived
3
0
Fork 0

Grooming and fix reported message length.

master
Philippe Pittoli 2023-01-04 13:06:29 +01:00
parent ce28b72f3b
commit 1a6c13c85d
1 changed files with 5 additions and 6 deletions

View File

@ -208,21 +208,20 @@ pub fn receive_fd(sockfd: os.socket_t, buffer: []u8, msg_size: *usize) !os.fd_t
.name = undefined,
.namelen = 0,
.iov = &iov,
.iovlen = iov.len,
.iovlen = 1,
.control = &cmsg,
.controllen = @sizeOf(@TypeOf(cmsg)),
.flags = 0,
};
_ = recvmsg(sockfd, msg, 0) catch |err| {
print("error sendmsg failed with {s}", .{@errorName(err)});
var msglen = recvmsg(sockfd, msg, 0) catch |err| {
print("error recvmsg failed with {s}", .{@errorName(err)});
return 0;
};
var received_fd = @as(i32, cmsg.dataPtr().*);
// print("received {} bytes, fd is {}\n", .{len, received_fd});
// print("payload (iov base) {s}\n", .{iov[0].iov_base[0..iov[0].iov_len - 1]});
std.mem.copy(u8, buffer, &msg_buffer);
msg_size.* = iov[0].iov_len;
msg_size.* = msglen;
return received_fd;
}