sysdeps/managarm: Convert sys_socket to bragi
@@ -911,40 +911,27 @@ int sys_socket(int domain, int type_and_flags, int proto, int *fd) {
__ensure(!((type_and_flags & flags_mask) & ~(SOCK_CLOEXEC | SOCK_NONBLOCK)));
SignalGuard sguard;
- HelAction actions[3];
- globalQueue.trim();
- managarm::posix::CntRequest<MemoryAllocator> req(getSysdepsAllocator());
- req.set_request_type(managarm::posix::CntReqType::SOCKET);
+ managarm::posix::SocketRequest<MemoryAllocator> req(getSysdepsAllocator());
req.set_domain(domain);
req.set_socktype(type_and_flags & type_mask);
req.set_protocol(proto);
req.set_flags(type_and_flags & flags_mask);
- 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(getPosixLane(), actions, 3,
- globalQueue.getQueue(), 0, 0));
-
- auto element = globalQueue.dequeueSingle();
- auto offer = parseSimple(element);
- auto send_req = parseSimple(element);
- auto recv_resp = parseInline(element);
+ auto [offer, sendReq, recvResp] = exchangeMsgsSync(
+ getPosixLane(),
+ 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);
+ HEL_CHECK(offer.error());
+ HEL_CHECK(sendReq.error());
+ HEL_CHECK(recvResp.error());
managarm::posix::SvrResponse<MemoryAllocator> resp(getSysdepsAllocator());
- resp.ParseFromArray(recv_resp->data, recv_resp->length);
+ resp.ParseFromArray(recvResp.data(), recvResp.length());
__ensure(resp.error() == managarm::posix::Errors::SUCCESS);
*fd = resp.fd();
return 0;
