CFDataRef Monitor::receive_request(CFMessagePortRef local, SInt32 msgid, CFDataRef data, void *info) { Monitor *monitor = (Monitor *)info; CFIndex length = CFDataGetLength(data); memcpy(monitor->_request, CFDataGetBytePtr(data), length); CFDataRef reply = monitor->_response_buffer = CFDataCreateMutable(kCFAllocatorMallocZone, 0); // sample the stack. monitor->_stack_bottom = (void*) auto_get_sp(); // scan args monitor->tokenize_args(); // prevent the collector from collecting until we've processed the request. Zone *zone = Zone::zone(); if (zone) zone->block_collector(); // process request generating report monitor->process_request(); // unblock the collector. if (zone) zone->unblock_collector(); // return the response. CFDataAppendBytes(monitor->_response_buffer, (const UInt8*)"\0", 1); monitor->_response_buffer = NULL; return reply; }