| OLD | NEW |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 request.header.msgh_local_port = LocalPort(); | 458 request.header.msgh_local_port = LocalPort(); |
| 459 break; | 459 break; |
| 460 case Options::kReplyPortNull: | 460 case Options::kReplyPortNull: |
| 461 request.header.msgh_local_port = MACH_PORT_NULL; | 461 request.header.msgh_local_port = MACH_PORT_NULL; |
| 462 break; | 462 break; |
| 463 case Options::kReplyPortDead: { | 463 case Options::kReplyPortDead: { |
| 464 // Use a newly-allocated receive right that will be destroyed when this | 464 // Use a newly-allocated receive right that will be destroyed when this |
| 465 // method returns. A send right will be made from this receive right and | 465 // method returns. A send right will be made from this receive right and |
| 466 // carried in the request message to the server. By the time the server | 466 // carried in the request message to the server. By the time the server |
| 467 // looks at the right, it will have become a dead name. | 467 // looks at the right, it will have become a dead name. |
| 468 kr = mach_port_allocate(mach_task_self(), | 468 local_receive_port_owner.reset(NewMachPort(MACH_PORT_RIGHT_RECEIVE)); |
| 469 MACH_PORT_RIGHT_RECEIVE, | 469 ASSERT_NE(kMachPortNull, local_receive_port_owner); |
| 470 &request.header.msgh_local_port); | 470 request.header.msgh_local_port = local_receive_port_owner; |
| 471 ASSERT_EQ(KERN_SUCCESS, kr) | |
| 472 << MachErrorMessage(kr, "mach_port_allocate"); | |
| 473 local_receive_port_owner.reset(request.header.msgh_local_port); | |
| 474 break; | 471 break; |
| 475 } | 472 } |
| 476 } | 473 } |
| 477 request.header.msgh_id = kRequestMessageID; | 474 request.header.msgh_id = kRequestMessageID; |
| 478 if (options_.client_send_complex) { | 475 if (options_.client_send_complex) { |
| 479 // Allocate a new receive right in this process and make a send right that | 476 // Allocate a new receive right in this process and make a send right that |
| 480 // will appear in the parent process. This is used to test that the server | 477 // will appear in the parent process. This is used to test that the server |
| 481 // properly handles ownership of resources received in complex messages. | 478 // properly handles ownership of resources received in complex messages. |
| 482 request.body.msgh_descriptor_count = 1; | 479 request.body.msgh_descriptor_count = 1; |
| 483 kr = mach_port_allocate(mach_task_self(), | 480 child_complex_message_port_.reset(NewMachPort(MACH_PORT_RIGHT_RECEIVE)); |
| 484 MACH_PORT_RIGHT_RECEIVE, | 481 ASSERT_NE(kMachPortNull, child_complex_message_port_); |
| 485 &request.port_descriptor.name); | 482 request.port_descriptor.name = child_complex_message_port_; |
| 486 ASSERT_EQ(KERN_SUCCESS, kr) | |
| 487 << MachErrorMessage(kr, "mach_port_allocate"); | |
| 488 child_complex_message_port_.reset(request.port_descriptor.name); | |
| 489 request.port_descriptor.disposition = MACH_MSG_TYPE_MAKE_SEND; | 483 request.port_descriptor.disposition = MACH_MSG_TYPE_MAKE_SEND; |
| 490 request.port_descriptor.type = MACH_MSG_PORT_DESCRIPTOR; | 484 request.port_descriptor.type = MACH_MSG_PORT_DESCRIPTOR; |
| 491 } else { | 485 } else { |
| 492 request.body.msgh_descriptor_count = 0; | 486 request.body.msgh_descriptor_count = 0; |
| 493 request.port_descriptor.name = MACH_PORT_NULL; | 487 request.port_descriptor.name = MACH_PORT_NULL; |
| 494 request.port_descriptor.disposition = 0; | 488 request.port_descriptor.disposition = 0; |
| 495 request.port_descriptor.type = 0; | 489 request.port_descriptor.type = 0; |
| 496 } | 490 } |
| 497 request.ndr = NDR_record; | 491 request.ndr = NDR_record; |
| 498 request.number = requests_++; | 492 request.number = requests_++; |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 options.expect_server_transaction_count = 0; | 844 options.expect_server_transaction_count = 0; |
| 851 options.client_send_large = true; | 845 options.client_send_large = true; |
| 852 options.client_expect_reply = false; | 846 options.client_expect_reply = false; |
| 853 TestMachMessageServer test_mach_message_server(options); | 847 TestMachMessageServer test_mach_message_server(options); |
| 854 test_mach_message_server.Test(); | 848 test_mach_message_server.Test(); |
| 855 } | 849 } |
| 856 | 850 |
| 857 } // namespace | 851 } // namespace |
| 858 } // namespace test | 852 } // namespace test |
| 859 } // namespace crashpad | 853 } // namespace crashpad |
| OLD | NEW |