@@ -25,12 +25,13 @@ extension Mach {
25
25
public func doRoutine(
26
26
_ routineIndex: mach_msg_id_t ,
27
27
request: MIGRequest < some Mach . MIGPayload > ,
28
- on replyPort: Mach . Port ? = nil
28
+ replyPort: Mach . Port ? = nil
29
29
) throws -> MIGReply < Never > {
30
30
try self . doRoutine (
31
31
routineIndex,
32
32
request: request,
33
- replyPayloadType: Never . self
33
+ replyPayloadType: Never . self,
34
+ replyPort: replyPort
34
35
)
35
36
}
36
37
@@ -40,15 +41,15 @@ extension Mach {
40
41
_ routineIndex: mach_msg_id_t ,
41
42
request: MIGRequest < some Mach . MIGPayload > ,
42
43
replyPayloadType: ReplyPayload . Type ,
43
- on replyPort: Mach . Port = Mach . MIGReplyPort ( )
44
+ replyPort: Mach . Port ?
44
45
) throws -> Mach . MIGReply < ReplyPayload > {
45
46
let routineId = self . baseRoutineId + routineIndex
46
47
request. header. msgh_id = routineId
47
48
request. header. bits. remotePortDisposition = . copySend // make a copy of the send right so we can reuse the port
48
49
request. header. bits. localPortDisposition = . makeSendOnce // make a send-once right so we can receive the reply
49
50
let reply = try Mach . Message. send (
50
51
request, to: self ,
51
- receiving: Mach . MIGReply< ReplyPayload> . self , from: replyPort
52
+ receiving: Mach . MIGReply< ReplyPayload> . self , from: replyPort ?? Mach . MIGReplyPort ( )
52
53
)
53
54
guard reply. header. msgh_id != MACH_NOTIFY_SEND_ONCE else {
54
55
throw Mach . MIGError ( . serverDied)
0 commit comments