- mig_reply_error_t *bufRequest = 0, *bufReply = 0;
- register mach_msg_return_t mr;
- register kern_return_t kr;
-
- if ((kr = vm_allocate(mach_task_self(),
- (vm_address_t *)&bufRequest,
- max_size + MAX_TRAILER_SIZE,
- TRUE)) != KERN_SUCCESS)
- return kr;
- if ((kr = vm_protect(mach_task_self(),
- (vm_address_t)bufRequest,
- max_size + MAX_TRAILER_SIZE,
- FALSE, VM_PROT_ALL)) != KERN_SUCCESS)
- return kr;
- mlock(bufRequest, max_size + MAX_TRAILER_SIZE);
- if ((kr = vm_allocate(mach_task_self(),
- (vm_address_t *)&bufReply,
- max_size + MAX_TRAILER_SIZE,
- TRUE)) != KERN_SUCCESS)
- return kr;
- if ((kr = vm_protect(mach_task_self(),
- (vm_address_t)bufReply,
- max_size + MAX_TRAILER_SIZE,
- FALSE, VM_PROT_ALL)) != KERN_SUCCESS)
- return kr;
- mlock(bufReply, max_size + MAX_TRAILER_SIZE);
- while(TRUE) {
- mr = mach_msg(&bufRequest->Head, MACH_RCV_MSG|options,
- 0, max_size, rcv_name,
- MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
- if (mr == MACH_MSG_SUCCESS) {
- /* we have a request message */
-
- if(!(default_pager_alerts_server(
- &bufRequest->Head, &bufReply->Head)))
- backing_store_triggers_server(
- &bufRequest->Head, &bufReply->Head);
-
- if (!(bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) &&
- bufReply->RetCode != KERN_SUCCESS) {
- if (bufReply->RetCode == MIG_NO_REPLY)
- /*
- * This return code is a little tricky--
- * it appears that the demux routine found an
- * error of some sort, but since that error
- * would not normally get returned either to
- * the local user or the remote one, we pretend it's
- * ok.
- */
-
- bufRequest->Head.msgh_remote_port = MACH_PORT_NULL;
- mach_msg_destroy(&bufRequest->Head);
- continue;
- }
-
- if (bufReply->Head.msgh_remote_port == MACH_PORT_NULL) {
- /* no reply port, so destroy the reply */
- if (bufReply->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX)
- mach_msg_destroy(&bufReply->Head);
- } else {
- break;
- }
- } else {
- break;
- }
- }
-
- (void)vm_deallocate(mach_task_self(),
- (vm_address_t) bufRequest,
- max_size + MAX_TRAILER_SIZE);
- (void)vm_deallocate(mach_task_self(),
- (vm_address_t) bufReply,
- max_size + MAX_TRAILER_SIZE);
- return KERN_FAILURE;
-
-}
-
-
-kern_return_t
-backing_store_triggers(dynamic_pager, hi_wat, flags, port)
- mach_port_t dynamic_pager;
- int hi_wat;
- int flags;
- mach_port_t port;
-{
- int cur_limits;
-
- if (file_count > max_valid)
- cur_limits = max_valid;
- else
- cur_limits = file_count;
-
- if((hi_wat + limits[cur_limits].size) > limits[cur_limits].low_water)
- return KERN_FAILURE; /* let ipc system clean up port */
-
- /* If there was a previous registration, throw it away */
- if (notify_port != MACH_PORT_NULL) {
- mach_port_deallocate(mach_task_self(), notify_port);
- notify_port = MACH_PORT_NULL;
- }
-
- notify_port = port;
- notify_high = hi_wat;
- if(hi_water < notify_high) {
- local_hi_water = notify_high;
- } else {
- local_hi_water = hi_water;