OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/edk/system/channel.h" | 5 #include "mojo/edk/system/channel.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 #else | 393 #else |
394 handles.reset(); | 394 handles.reset(); |
395 #endif // defined(OS_MACOSX) | 395 #endif // defined(OS_MACOSX) |
396 } | 396 } |
397 } else { | 397 } else { |
398 result = PlatformChannelWrite(handle_.get(), message_view.data(), | 398 result = PlatformChannelWrite(handle_.get(), message_view.data(), |
399 message_view.data_num_bytes()); | 399 message_view.data_num_bytes()); |
400 } | 400 } |
401 | 401 |
402 if (result < 0) { | 402 if (result < 0) { |
403 if (errno != EAGAIN && errno != EWOULDBLOCK) | 403 if (errno != EAGAIN && errno != EWOULDBLOCK |
| 404 #if defined(OS_MACOSX) |
| 405 // On OS X if sendmsg() is trying to send fds between processes and |
| 406 // there isn't enough room in the output buffer to send the fd |
| 407 // structure over atomically then EMSGSIZE is returned. |
| 408 // |
| 409 // EMSGSIZE presents a problem since the system APIs can only call |
| 410 // us when there's room in the socket buffer and not when there is |
| 411 // "enough" room. |
| 412 // |
| 413 // The current behavior is to return to the event loop when EMSGSIZE |
| 414 // is received and hopefull service another FD. This is however |
| 415 // still technically a busy wait since the event loop will call us |
| 416 // right back until the receiver has read enough data to allow |
| 417 // passing the FD over atomically. |
| 418 && errno != EMSGSIZE |
| 419 #endif |
| 420 ) { |
404 return false; | 421 return false; |
| 422 } |
405 message_view.SetHandles(std::move(handles)); | 423 message_view.SetHandles(std::move(handles)); |
406 outgoing_messages_.emplace_front(std::move(message_view)); | 424 outgoing_messages_.emplace_front(std::move(message_view)); |
407 WaitForWriteOnIOThreadNoLock(); | 425 WaitForWriteOnIOThreadNoLock(); |
408 return true; | 426 return true; |
409 } | 427 } |
410 | 428 |
411 bytes_written = static_cast<size_t>(result); | 429 bytes_written = static_cast<size_t>(result); |
412 } while (bytes_written < message_view.data_num_bytes()); | 430 } while (bytes_written < message_view.data_num_bytes()); |
413 | 431 |
414 return FlushOutgoingMessagesNoLock(); | 432 return FlushOutgoingMessagesNoLock(); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 // static | 559 // static |
542 scoped_refptr<Channel> Channel::Create( | 560 scoped_refptr<Channel> Channel::Create( |
543 Delegate* delegate, | 561 Delegate* delegate, |
544 ScopedPlatformHandle platform_handle, | 562 ScopedPlatformHandle platform_handle, |
545 scoped_refptr<base::TaskRunner> io_task_runner) { | 563 scoped_refptr<base::TaskRunner> io_task_runner) { |
546 return new ChannelPosix(delegate, std::move(platform_handle), io_task_runner); | 564 return new ChannelPosix(delegate, std::move(platform_handle), io_task_runner); |
547 } | 565 } |
548 | 566 |
549 } // namespace edk | 567 } // namespace edk |
550 } // namespace mojo | 568 } // namespace mojo |
OLD | NEW |