]> git.saurik.com Git - apple/libc.git/blob - mach/mach_msg.c
3771c26e520d4317c70068dda563ec154982f17d
[apple/libc.git] / mach / mach_msg.c
1 /*
2 * Copyright (c) 1999-2002 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * Mach Operating System
27 * Copyright (c) 1991,1990,1989 Carnegie Mellon University
28 * All Rights Reserved.
29 *
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
35 *
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
39 *
40 * Carnegie Mellon requests users of this software to return to
41 *
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
46 *
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
49 */
50
51 #include <stdlib.h>
52 #include <mach/mach.h>
53 #include <mach/boolean.h>
54 #include <mach/kern_return.h>
55 #include <mach/message.h>
56 #include <mach/mig_errors.h>
57 #include <mach/vm_statistics.h>
58
59 #ifdef HOST_MACH_MSG_TRAP
60 __private_extern__ kern_return_t _host_mach_msg_trap_return_ = KERN_FAILURE;
61
62 #define MACH_MSG_TRAP(msg, opt, ssize, rsize, rname, to, not) \
63 ((_host_mach_msg_trap_return_ == KERN_SUCCESS) ? \
64 mach_msg_trap((msg), (opt), (ssize), (rsize), (rname), (to), (not)) : \
65 mach_msg_overwrite_trap((msg), (opt), (ssize), (rsize), (rname), \
66 (to), (not), MACH_MSG_NULL, 0))
67
68 #else
69
70 #define MACH_MSG_TRAP(msg, opt, ssize, rsize, rname, to, not) \
71 mach_msg_overwrite_trap((msg), (opt), (ssize), (rsize), (rname), \
72 (to), (not), MACH_MSG_NULL, 0))
73 #endif
74
75 #define LIBMACH_OPTIONS (MACH_SEND_INTERRUPT|MACH_RCV_INTERRUPT)
76
77 /*
78 * Routine: mach_msg
79 * Purpose:
80 * Send and/or receive a message. If the message operation
81 * is interrupted, and the user did not request an indication
82 * of that fact, then restart the appropriate parts of the
83 * operation.
84 */
85 mach_msg_return_t
86 mach_msg(msg, option, send_size, rcv_size, rcv_name, timeout, notify)
87 mach_msg_header_t *msg;
88 mach_msg_option_t option;
89 mach_msg_size_t send_size;
90 mach_msg_size_t rcv_size;
91 mach_port_t rcv_name;
92 mach_msg_timeout_t timeout;
93 mach_port_t notify;
94 {
95 mach_msg_return_t mr;
96
97 /*
98 * Consider the following cases:
99 * 1) Errors in pseudo-receive (eg, MACH_SEND_INTERRUPTED
100 * plus special bits).
101 * 2) Use of MACH_SEND_INTERRUPT/MACH_RCV_INTERRUPT options.
102 * 3) RPC calls with interruptions in one/both halves.
103 *
104 * We refrain from passing the option bits that we implement
105 * to the kernel. This prevents their presence from inhibiting
106 * the kernel's fast paths (when it checks the option value).
107 */
108
109 mr = MACH_MSG_TRAP(msg, option &~ LIBMACH_OPTIONS,
110 send_size, rcv_size, rcv_name,
111 timeout, notify);
112 if (mr == MACH_MSG_SUCCESS)
113 return MACH_MSG_SUCCESS;
114
115 if ((option & MACH_SEND_INTERRUPT) == 0)
116 while (mr == MACH_SEND_INTERRUPTED)
117 mr = MACH_MSG_TRAP(msg,
118 option &~ LIBMACH_OPTIONS,
119 send_size, rcv_size, rcv_name,
120 timeout, notify);
121
122 if ((option & MACH_RCV_INTERRUPT) == 0)
123 while (mr == MACH_RCV_INTERRUPTED)
124 mr = MACH_MSG_TRAP(msg,
125 option &~ (LIBMACH_OPTIONS|MACH_SEND_MSG),
126 0, rcv_size, rcv_name,
127 timeout, notify);
128
129 return mr;
130 }
131
132 /*
133 * Routine: mach_msg_overwrite
134 * Purpose:
135 * Send and/or receive a message. If the message operation
136 * is interrupted, and the user did not request an indication
137 * of that fact, then restart the appropriate parts of the
138 * operation.
139 *
140 * Distinct send and receive buffers may be specified. If
141 * no separate receive buffer is specified, the msg parameter
142 * will be used for both send and receive operations.
143 *
144 * In addition to a distinct receive buffer, that buffer may
145 * already contain scatter control information to direct the
146 * receiving of the message.
147 */
148 mach_msg_return_t
149 mach_msg_overwrite(msg, option, send_size, rcv_limit, rcv_name, timeout,
150 notify, rcv_msg, rcv_scatter_size)
151 mach_msg_header_t *msg;
152 mach_msg_option_t option;
153 mach_msg_size_t send_size;
154 mach_msg_size_t rcv_limit;
155 mach_port_t rcv_name;
156 mach_msg_timeout_t timeout;
157 mach_port_t notify;
158 mach_msg_header_t *rcv_msg;
159 mach_msg_size_t rcv_scatter_size;
160 {
161 mach_msg_return_t mr;
162
163 /*
164 * Consider the following cases:
165 * 1) Errors in pseudo-receive (eg, MACH_SEND_INTERRUPTED
166 * plus special bits).
167 * 2) Use of MACH_SEND_INTERRUPT/MACH_RCV_INTERRUPT options.
168 * 3) RPC calls with interruptions in one/both halves.
169 *
170 * We refrain from passing the option bits that we implement
171 * to the kernel. This prevents their presence from inhibiting
172 * the kernel's fast paths (when it checks the option value).
173 */
174
175 mr = mach_msg_overwrite_trap(msg, option &~ LIBMACH_OPTIONS,
176 send_size, rcv_limit, rcv_name,
177 timeout, notify, rcv_msg, rcv_scatter_size);
178 if (mr == MACH_MSG_SUCCESS)
179 return MACH_MSG_SUCCESS;
180
181 if ((option & MACH_SEND_INTERRUPT) == 0)
182 while (mr == MACH_SEND_INTERRUPTED)
183 mr = mach_msg_overwrite_trap(msg,
184 option &~ LIBMACH_OPTIONS,
185 send_size, rcv_limit, rcv_name,
186 timeout, notify, rcv_msg, rcv_scatter_size);
187
188 if ((option & MACH_RCV_INTERRUPT) == 0)
189 while (mr == MACH_RCV_INTERRUPTED)
190 mr = mach_msg_overwrite_trap(msg,
191 option &~ (LIBMACH_OPTIONS|MACH_SEND_MSG),
192 0, rcv_limit, rcv_name,
193 timeout, notify, rcv_msg, rcv_scatter_size);
194
195 return mr;
196 }
197
198
199 mach_msg_return_t
200 mach_msg_send(mach_msg_header_t *msg)
201 {
202 return mach_msg(msg, MACH_SEND_MSG,
203 msg->msgh_size, 0, MACH_PORT_NULL,
204 MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
205 }
206
207 mach_msg_return_t
208 mach_msg_receive(mach_msg_header_t *msg)
209 {
210 return mach_msg(msg, MACH_RCV_MSG,
211 0, msg->msgh_size, msg->msgh_local_port,
212 MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
213 }
214
215
216 static void
217 mach_msg_destroy_port(mach_port_t port, mach_msg_type_name_t type)
218 {
219 if (MACH_PORT_VALID(port)) switch (type) {
220 case MACH_MSG_TYPE_MOVE_SEND:
221 case MACH_MSG_TYPE_MOVE_SEND_ONCE:
222 /* destroy the send/send-once right */
223 (void) mach_port_deallocate(mach_task_self(), port);
224 break;
225
226 case MACH_MSG_TYPE_MOVE_RECEIVE:
227 /* destroy the receive right */
228 (void) mach_port_mod_refs(mach_task_self(), port,
229 MACH_PORT_RIGHT_RECEIVE, -1);
230 break;
231
232 case MACH_MSG_TYPE_MAKE_SEND:
233 /* create a send right and then destroy it */
234 (void) mach_port_insert_right(mach_task_self(), port,
235 port, MACH_MSG_TYPE_MAKE_SEND);
236 (void) mach_port_deallocate(mach_task_self(), port);
237 break;
238
239 case MACH_MSG_TYPE_MAKE_SEND_ONCE:
240 /* create a send-once right and then destroy it */
241 (void) mach_port_extract_right(mach_task_self(), port,
242 MACH_MSG_TYPE_MAKE_SEND_ONCE,
243 &port, &type);
244 (void) mach_port_deallocate(mach_task_self(), port);
245 break;
246 }
247 }
248
249 static void
250 mach_msg_destroy_memory(vm_offset_t addr, vm_size_t size)
251 {
252 if (size != 0)
253 (void) vm_deallocate(mach_task_self(), addr, size);
254 }
255
256
257 /*
258 * Routine: mach_msg_destroy
259 * Purpose:
260 * mach_msg_destroy is useful in two contexts.
261 *
262 * First, it can deallocate all port rights and
263 * out-of-line memory in a received message.
264 * When a server receives a request it doesn't want,
265 * it needs this functionality.
266 *
267 * Second, it can mimic the side-effects of a msg-send
268 * operation. The effect is as if the message were sent
269 * and then destroyed inside the kernel. When a server
270 * can't send a reply (because the client died),
271 * it needs this functionality.
272 */
273 void
274 mach_msg_destroy(mach_msg_header_t *msg)
275 {
276 mach_msg_bits_t mbits = msg->msgh_bits;
277
278 /*
279 * The msgh_local_port field doesn't hold a port right.
280 * The receive operation consumes the destination port right.
281 */
282
283 mach_msg_destroy_port(msg->msgh_remote_port, MACH_MSGH_BITS_REMOTE(mbits));
284
285 if (mbits & MACH_MSGH_BITS_COMPLEX) {
286 mach_msg_body_t *body;
287 mach_msg_descriptor_t *saddr, *eaddr;
288
289 body = (mach_msg_body_t *) (msg + 1);
290 saddr = (mach_msg_descriptor_t *)
291 ((mach_msg_base_t *) msg + 1);
292 eaddr = saddr + body->msgh_descriptor_count;
293
294 for ( ; saddr < eaddr; saddr++) {
295 switch (saddr->type.type) {
296
297 case MACH_MSG_PORT_DESCRIPTOR: {
298 mach_msg_port_descriptor_t *dsc;
299
300 /*
301 * Destroy port rights carried in the message
302 */
303 dsc = &saddr->port;
304 mach_msg_destroy_port(dsc->name, dsc->disposition);
305 break;
306 }
307
308 case MACH_MSG_OOL_DESCRIPTOR : {
309 mach_msg_ool_descriptor_t *dsc;
310
311 /*
312 * Destroy memory carried in the message
313 */
314 dsc = &saddr->out_of_line;
315 if (dsc->deallocate) {
316 mach_msg_destroy_memory((vm_offset_t)dsc->address,
317 dsc->size);
318 }
319 break;
320 }
321
322 case MACH_MSG_OOL_PORTS_DESCRIPTOR : {
323 mach_port_t *ports;
324 mach_msg_ool_ports_descriptor_t *dsc;
325 mach_msg_type_number_t j;
326
327 /*
328 * Destroy port rights carried in the message
329 */
330 dsc = &saddr->ool_ports;
331 ports = (mach_port_t *) dsc->address;
332 for (j = 0; j < dsc->count; j++, ports++) {
333 mach_msg_destroy_port(*ports, dsc->disposition);
334 }
335
336 /*
337 * Destroy memory carried in the message
338 */
339 if (dsc->deallocate) {
340 mach_msg_destroy_memory((vm_offset_t)dsc->address,
341 dsc->count * sizeof(mach_port_t));
342 }
343 break;
344 }
345 }
346 }
347 }
348 }
349
350 /*
351 * Routine: mach_msg_server_once
352 * Purpose:
353 * A simple generic server function. It allows more flexibility
354 * than mach_msg_server by processing only one message request
355 * and then returning to the user. Note that more in the way
356 * of error codes are returned to the user; specifically, any
357 * failing error from mach_msg calls will be returned
358 * (though errors from the demux routine or the routine it
359 * calls will not be).
360 */
361 mach_msg_return_t
362 mach_msg_server_once(
363 boolean_t (*demux)(mach_msg_header_t *, mach_msg_header_t *),
364 mach_msg_size_t max_size,
365 mach_port_t rcv_name,
366 mach_msg_options_t options)
367 {
368 mig_reply_error_t *bufRequest, *bufReply;
369 mach_msg_size_t request_size;
370 mach_msg_size_t request_alloc;
371 mach_msg_size_t trailer_alloc;
372 mach_msg_size_t reply_alloc;
373 mach_msg_return_t mr;
374 kern_return_t kr;
375 mach_port_t self = mach_task_self();
376
377 options &= ~(MACH_SEND_MSG|MACH_RCV_MSG);
378
379 trailer_alloc = REQUESTED_TRAILER_SIZE(options);
380 request_alloc = round_page(max_size + trailer_alloc);
381
382 request_size = (options & MACH_RCV_LARGE) ?
383 request_alloc : max_size + trailer_alloc;
384
385 reply_alloc = round_page((options & MACH_SEND_TRAILER) ?
386 (max_size + MAX_TRAILER_SIZE) :
387 max_size);
388
389 kr = vm_allocate(self,
390 (vm_address_t *)&bufReply,
391 reply_alloc,
392 VM_MAKE_TAG(VM_MEMORY_MACH_MSG)|TRUE);
393 if (kr != KERN_SUCCESS)
394 return kr;
395
396 for (;;) {
397 mach_msg_size_t new_request_alloc;
398
399 kr = vm_allocate(self,
400 (vm_address_t *)&bufRequest,
401 request_alloc,
402 VM_MAKE_TAG(VM_MEMORY_MACH_MSG)|TRUE);
403 if (kr != KERN_SUCCESS) {
404 vm_deallocate(self,
405 (vm_address_t)bufReply,
406 reply_alloc);
407 return kr;
408 }
409
410 mr = mach_msg(&bufRequest->Head, MACH_RCV_MSG|options,
411 0, request_size, rcv_name,
412 MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
413
414 if (!((mr == MACH_RCV_TOO_LARGE) && (options & MACH_RCV_LARGE)))
415 break;
416
417 new_request_alloc = round_page(bufRequest->Head.msgh_size +
418 trailer_alloc);
419 vm_deallocate(self,
420 (vm_address_t) bufRequest,
421 request_alloc);
422 request_size = request_alloc = new_request_alloc;
423 }
424
425 if (mr == MACH_MSG_SUCCESS) {
426 /* we have a request message */
427
428 (void) (*demux)(&bufRequest->Head, &bufReply->Head);
429
430 if (!(bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) {
431 if (bufReply->RetCode == MIG_NO_REPLY)
432 bufReply->Head.msgh_remote_port = MACH_PORT_NULL;
433 else if ((bufReply->RetCode != KERN_SUCCESS) &&
434 (bufRequest->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) {
435 /* destroy the request - but not the reply port */
436 bufRequest->Head.msgh_remote_port = MACH_PORT_NULL;
437 mach_msg_destroy(&bufRequest->Head);
438 }
439 }
440
441 /*
442 * We don't want to block indefinitely because the client
443 * isn't receiving messages from the reply port.
444 * If we have a send-once right for the reply port, then
445 * this isn't a concern because the send won't block.
446 * If we have a send right, we need to use MACH_SEND_TIMEOUT.
447 * To avoid falling off the kernel's fast RPC path unnecessarily,
448 * we only supply MACH_SEND_TIMEOUT when absolutely necessary.
449 */
450 if (bufReply->Head.msgh_remote_port != MACH_PORT_NULL) {
451
452 mr = mach_msg(&bufReply->Head,
453 (MACH_MSGH_BITS_REMOTE(bufReply->Head.msgh_bits) ==
454 MACH_MSG_TYPE_MOVE_SEND_ONCE) ?
455 MACH_SEND_MSG|options :
456 MACH_SEND_MSG|MACH_SEND_TIMEOUT|options,
457 bufReply->Head.msgh_size, 0, MACH_PORT_NULL,
458 MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
459
460 if ((mr != MACH_SEND_INVALID_DEST) &&
461 (mr != MACH_SEND_TIMED_OUT))
462 goto done_once;
463 mr = MACH_MSG_SUCCESS;
464 }
465 if (bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)
466 mach_msg_destroy(&bufReply->Head);
467 }
468
469 done_once:
470 (void)vm_deallocate(self,
471 (vm_address_t) bufRequest,
472 request_alloc);
473 (void)vm_deallocate(self,
474 (vm_address_t) bufReply,
475 reply_alloc);
476 return mr;
477 }
478
479 /*
480 * Routine: mach_msg_server
481 * Purpose:
482 * A simple generic server function. Note that changes here
483 * should be considered for duplication above.
484 */
485 mach_msg_return_t
486 mach_msg_server(
487 boolean_t (*demux)(mach_msg_header_t *, mach_msg_header_t *),
488 mach_msg_size_t max_size,
489 mach_port_t rcv_name,
490 mach_msg_options_t options)
491 {
492 mig_reply_error_t *bufRequest, *bufReply;
493 mach_msg_size_t request_size;
494 mach_msg_size_t new_request_alloc;
495 mach_msg_size_t request_alloc;
496 mach_msg_size_t trailer_alloc;
497 mach_msg_size_t reply_alloc;
498 mach_msg_return_t mr;
499 kern_return_t kr;
500 mach_port_t self = mach_task_self();
501
502 options &= ~(MACH_SEND_MSG|MACH_RCV_MSG);
503
504 reply_alloc = round_page((options & MACH_SEND_TRAILER) ?
505 (max_size + MAX_TRAILER_SIZE) : max_size);
506
507 kr = vm_allocate(self,
508 (vm_address_t *)&bufReply,
509 reply_alloc,
510 VM_MAKE_TAG(VM_MEMORY_MACH_MSG)|TRUE);
511 if (kr != KERN_SUCCESS)
512 return kr;
513
514 request_alloc = 0;
515 trailer_alloc = REQUESTED_TRAILER_SIZE(options);
516 new_request_alloc = round_page(max_size + trailer_alloc);
517
518 request_size = (options & MACH_RCV_LARGE) ?
519 new_request_alloc : max_size + trailer_alloc;
520
521 for (;;) {
522 if (request_alloc < new_request_alloc) {
523 request_alloc = new_request_alloc;
524 kr = vm_allocate(self,
525 (vm_address_t *)&bufRequest,
526 request_alloc,
527 VM_MAKE_TAG(VM_MEMORY_MACH_MSG)|TRUE);
528 if (kr != KERN_SUCCESS) {
529 vm_deallocate(self,
530 (vm_address_t)bufReply,
531 reply_alloc);
532 return kr;
533 }
534 }
535
536 mr = mach_msg(&bufRequest->Head, MACH_RCV_MSG|options,
537 0, request_size, rcv_name,
538 MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
539
540 while (mr == MACH_MSG_SUCCESS) {
541 /* we have another request message */
542
543 (void) (*demux)(&bufRequest->Head, &bufReply->Head);
544
545 if (!(bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) {
546 if (bufReply->RetCode == MIG_NO_REPLY)
547 bufReply->Head.msgh_remote_port = MACH_PORT_NULL;
548 else if ((bufReply->RetCode != KERN_SUCCESS) &&
549 (bufRequest->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)) {
550 /* destroy the request - but not the reply port */
551 bufRequest->Head.msgh_remote_port = MACH_PORT_NULL;
552 mach_msg_destroy(&bufRequest->Head);
553 }
554 }
555
556 /*
557 * We don't want to block indefinitely because the client
558 * isn't receiving messages from the reply port.
559 * If we have a send-once right for the reply port, then
560 * this isn't a concern because the send won't block.
561 * If we have a send right, we need to use MACH_SEND_TIMEOUT.
562 * To avoid falling off the kernel's fast RPC path,
563 * we only supply MACH_SEND_TIMEOUT when absolutely necessary.
564 */
565 if (bufReply->Head.msgh_remote_port != MACH_PORT_NULL) {
566 if (request_alloc == reply_alloc) {
567 mig_reply_error_t *bufTemp;
568
569 mr = mach_msg(
570 &bufReply->Head,
571 (MACH_MSGH_BITS_REMOTE(bufReply->Head.msgh_bits) ==
572 MACH_MSG_TYPE_MOVE_SEND_ONCE) ?
573 MACH_SEND_MSG|MACH_RCV_MSG|options :
574 MACH_SEND_MSG|MACH_RCV_MSG|MACH_SEND_TIMEOUT|options,
575 bufReply->Head.msgh_size, request_size, rcv_name,
576 MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
577
578 /* swap request and reply */
579 bufTemp = bufRequest;
580 bufRequest = bufReply;
581 bufReply = bufTemp;
582
583 } else {
584 mr = mach_msg_overwrite(
585 &bufReply->Head,
586 (MACH_MSGH_BITS_REMOTE(bufReply->Head.msgh_bits) ==
587 MACH_MSG_TYPE_MOVE_SEND_ONCE) ?
588 MACH_SEND_MSG|MACH_RCV_MSG|options :
589 MACH_SEND_MSG|MACH_RCV_MSG|MACH_SEND_TIMEOUT|options,
590 bufReply->Head.msgh_size, request_size, rcv_name,
591 MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL,
592 &bufRequest->Head, request_size);
593 }
594
595 if ((mr != MACH_SEND_INVALID_DEST) &&
596 (mr != MACH_SEND_TIMED_OUT))
597 continue;
598 }
599 if (bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)
600 mach_msg_destroy(&bufReply->Head);
601
602 mr = mach_msg(&bufRequest->Head, MACH_RCV_MSG|options,
603 0, request_size, rcv_name,
604 MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
605
606 } /* while (mr == MACH_MSG_SUCCESS) */
607
608 if ((mr == MACH_RCV_TOO_LARGE) && (options & MACH_RCV_LARGE)) {
609 new_request_alloc = round_page(bufRequest->Head.msgh_size +
610 trailer_alloc);
611 request_size = new_request_alloc;
612 vm_deallocate(self,
613 (vm_address_t) bufRequest,
614 request_alloc);
615 continue;
616 }
617
618 break;
619
620 } /* for(;;) */
621
622 (void)vm_deallocate(self,
623 (vm_address_t) bufRequest,
624 request_alloc);
625 (void)vm_deallocate(self,
626 (vm_address_t) bufReply,
627 reply_alloc);
628 return mr;
629 }