OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/raw_channel.h" | 5 #include "mojo/edk/system/raw_channel.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 RawChannel* RawChannel::Create(ScopedPlatformHandle handle) { | 559 RawChannel* RawChannel::Create(ScopedPlatformHandle handle) { |
560 return new RawChannelPosix(handle.Pass()); | 560 return new RawChannelPosix(handle.Pass()); |
561 } | 561 } |
562 | 562 |
563 size_t RawChannel::GetSerializedPlatformHandleSize() { | 563 size_t RawChannel::GetSerializedPlatformHandleSize() { |
564 // We don't actually need any space on POSIX (since we just send FDs). | 564 // We don't actually need any space on POSIX (since we just send FDs). |
565 return 0; | 565 return 0; |
566 } | 566 } |
567 | 567 |
568 bool RawChannel::IsOtherEndOf(RawChannel* other) { | 568 bool RawChannel::IsOtherEndOf(RawChannel* other) { |
| 569 #if defined(OFFICIAL_BUILD) |
| 570 return false; |
| 571 #else |
| 572 // We don't check the return code of getsockopt because this is only available |
| 573 // on Linux after 3.4. This is a developer error, so we just have to catch it |
| 574 // on platforms that developers use. |
| 575 // Note that since we're storing a 32 bit integer, we can get collisions so we |
| 576 // will only use it in non-official builds. |
569 DCHECK_NE(other, this); | 577 DCHECK_NE(other, this); |
570 PlatformHandle this_handle = static_cast<RawChannelPosix*>(this)->GetFD(); | 578 PlatformHandle this_handle = static_cast<RawChannelPosix*>(this)->GetFD(); |
571 PlatformHandle other_handle = static_cast<RawChannelPosix*>(other)->GetFD(); | 579 PlatformHandle other_handle = static_cast<RawChannelPosix*>(other)->GetFD(); |
572 | 580 |
573 // We don't check the return code of getsockopt because this is only available | |
574 // on Linux after 3.4. This is a developer error, so we just have to catch it | |
575 // on platforms that developers use. | |
576 int id1 = 0; | 581 int id1 = 0; |
577 int id2 = 1; | 582 int id2 = 1; |
578 socklen_t peek_off_size = sizeof(id1); | 583 socklen_t peek_off_size = sizeof(id1); |
579 getsockopt(this_handle.fd, SOL_SOCKET, SO_PEEK_OFF, &id1, &peek_off_size); | 584 getsockopt(this_handle.fd, SOL_SOCKET, SO_PEEK_OFF, &id1, &peek_off_size); |
580 getsockopt(other_handle.fd, SOL_SOCKET, SO_PEEK_OFF, &id2, &peek_off_size); | 585 getsockopt(other_handle.fd, SOL_SOCKET, SO_PEEK_OFF, &id2, &peek_off_size); |
581 return id1 == id2; | 586 return id1 == id2; |
| 587 #endif |
582 } | 588 } |
583 | 589 |
584 } // namespace edk | 590 } // namespace edk |
585 } // namespace mojo | 591 } // namespace mojo |
OLD | NEW |