sysdeps/managarm: convert sys_setsockopt to helix_ng
@@ -265,9 +265,6 @@ int sys_setsockopt(int fd, int layer, int number,
__ensure(size == sizeof(int));
memcpy(&value, buffer, sizeof(int));
- HelAction actions[3];
- globalQueue.trim();
-
auto handle = getHandleForFd(fd);
if (!handle)
return EBADF;
@@ -277,30 +274,18 @@ int sys_setsockopt(int fd, int layer, int number,
req.set_command(SO_PASSCRED);
req.set_value(value);
- frg::string<MemoryAllocator> ser(getSysdepsAllocator());
- req.SerializeToString(&ser);
- actions[0].type = kHelActionOffer;
- actions[0].flags = kHelItemAncillary;
- actions[1].type = kHelActionSendFromBuffer;
- actions[1].flags = kHelItemChain;
- actions[1].buffer = ser.data();
- actions[1].length = ser.size();
- actions[2].type = kHelActionRecvInline;
- actions[2].flags = 0;
- HEL_CHECK(helSubmitAsync(handle, actions, 3,
- globalQueue.getQueue(), 0, 0));
-
- auto element = globalQueue.dequeueSingle();
- auto offer = parseHandle(element);
- auto send_req = parseSimple(element);
- auto recv_resp = parseInline(element);
-
- HEL_CHECK(offer->error);
- HEL_CHECK(send_req->error);
- HEL_CHECK(recv_resp->error);
+ auto [offer, send_req, recv_resp] = exchangeMsgsSync(
+ handle,
+ helix_ng::offer(
+ helix_ng::sendBragiHeadOnly(req, getSysdepsAllocator()),
+ helix_ng::recvInline())
+ );
+ HEL_CHECK(offer.error());
+ HEL_CHECK(send_req.error());
+ HEL_CHECK(recv_resp.error());
managarm::fs::SvrResponse<MemoryAllocator> resp(getSysdepsAllocator());
- resp.ParseFromArray(recv_resp->data, recv_resp->length);
+ resp.ParseFromArray(recv_resp.data(), recv_resp.length());
__ensure(resp.error() == managarm::fs::Errors::SUCCESS);
return 0;
}else if(layer == SOL_SOCKET && number == SO_ATTACH_FILTER) {
