Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: mojo/edk/system/channel_posix.cc

Issue 2512463003: Mojo EDK: Correctly handle EMSGSIZE on Mac. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/test/ppapi/ppapi_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « chrome/test/ppapi/ppapi_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698