Boolean IODataQueue::initWithCapacity(UInt32 size)
{
+ vm_size_t allocSize = 0;
+
if (!super::init()) {
return false;
}
- dataQueue = (IODataQueueMemory *)IOMallocAligned(round_page_32(size + DATA_QUEUE_MEMORY_HEADER_SIZE), PAGE_SIZE);
+ allocSize = round_page(size + DATA_QUEUE_MEMORY_HEADER_SIZE);
+
+ if (allocSize < size) {
+ return false;
+ }
+
+ dataQueue = (IODataQueueMemory *)IOMallocAligned(allocSize, PAGE_SIZE);
if (dataQueue == 0) {
return false;
}
- dataQueue->queueSize = size;
- dataQueue->head = 0;
- dataQueue->tail = 0;
+ dataQueue->queueSize = size;
+ dataQueue->head = 0;
+ dataQueue->tail = 0;
return true;
}
void IODataQueue::free()
{
if (dataQueue) {
- IOFreeAligned(dataQueue, round_page_32(dataQueue->queueSize + DATA_QUEUE_MEMORY_HEADER_SIZE));
+ IOFreeAligned(dataQueue, round_page(dataQueue->queueSize + DATA_QUEUE_MEMORY_HEADER_SIZE));
}
super::free();
mach_msg_header_t * msgh;
msgh = (mach_msg_header_t *)notifyMsg;
- if (msgh) {
- kr = mach_msg_send_from_kernel(msgh, msgh->msgh_size);
+ if (msgh && msgh->msgh_remote_port) {
+ kr = mach_msg_send_from_kernel_proper(msgh, msgh->msgh_size);
switch(kr) {
case MACH_SEND_TIMED_OUT: // Notification already sent
case MACH_MSG_SUCCESS: