| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
| 7 | 7 |
| 8 #include <errno.h> // NOLINT | 8 #include <errno.h> // NOLINT |
| 9 #include <stdio.h> // NOLINT | 9 #include <stdio.h> // NOLINT |
| 10 #include <stdlib.h> // NOLINT | 10 #include <stdlib.h> // NOLINT |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 185 |
| 186 | 186 |
| 187 SocketAddress* Socket::GetRemotePeer(intptr_t fd, intptr_t* port) { | 187 SocketAddress* Socket::GetRemotePeer(intptr_t fd, intptr_t* port) { |
| 188 ASSERT(fd >= 0); | 188 ASSERT(fd >= 0); |
| 189 RawAddr raw; | 189 RawAddr raw; |
| 190 socklen_t size = sizeof(raw); | 190 socklen_t size = sizeof(raw); |
| 191 if (TEMP_FAILURE_RETRY_BLOCK_SIGNALS( | 191 if (TEMP_FAILURE_RETRY_BLOCK_SIGNALS( |
| 192 getpeername(fd, | 192 getpeername(fd, |
| 193 &raw.addr, | 193 &raw.addr, |
| 194 &size))) { | 194 &size))) { |
| 195 const int kBufferSize = 1024; | |
| 196 char error_buf[kBufferSize]; | |
| 197 Log::PrintErr("Error getpeername: %s\n", | |
| 198 strerror_r(errno, error_buf, kBufferSize)); | |
| 199 return NULL; | 195 return NULL; |
| 200 } | 196 } |
| 201 *port = SocketAddress::GetAddrPort(&raw); | 197 *port = SocketAddress::GetAddrPort(&raw); |
| 202 return new SocketAddress(&raw.addr); | 198 return new SocketAddress(&raw.addr); |
| 203 } | 199 } |
| 204 | 200 |
| 205 | 201 |
| 206 void Socket::GetError(intptr_t fd, OSError* os_error) { | 202 void Socket::GetError(intptr_t fd, OSError* os_error) { |
| 207 int len = sizeof(errno); | 203 int len = sizeof(errno); |
| 208 getsockopt(fd, | 204 getsockopt(fd, |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 mreq.gr_interface = interfaceIndex; | 614 mreq.gr_interface = interfaceIndex; |
| 619 memmove(&mreq.gr_group, &addr->ss, SocketAddress::GetAddrLength(addr)); | 615 memmove(&mreq.gr_group, &addr->ss, SocketAddress::GetAddrLength(addr)); |
| 620 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(setsockopt( | 616 return TEMP_FAILURE_RETRY_BLOCK_SIGNALS(setsockopt( |
| 621 fd, proto, MCAST_LEAVE_GROUP, &mreq, sizeof(mreq))) == 0; | 617 fd, proto, MCAST_LEAVE_GROUP, &mreq, sizeof(mreq))) == 0; |
| 622 } | 618 } |
| 623 | 619 |
| 624 } // namespace bin | 620 } // namespace bin |
| 625 } // namespace dart | 621 } // namespace dart |
| 626 | 622 |
| 627 #endif // defined(TARGET_OS_LINUX) | 623 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |