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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 Socket::SetNonBlocking(socket); | 374 Socket::SetNonBlocking(socket); |
375 } | 375 } |
376 return socket; | 376 return socket; |
377 } | 377 } |
378 | 378 |
379 | 379 |
380 void Socket::Close(intptr_t fd) { | 380 void Socket::Close(intptr_t fd) { |
381 ASSERT(fd >= 0); | 381 ASSERT(fd >= 0); |
382 int err = TEMP_FAILURE_RETRY(close(fd)); | 382 int err = TEMP_FAILURE_RETRY(close(fd)); |
383 if (err != 0) { | 383 if (err != 0) { |
384 const int kBufferSize = 1024; | 384 Log::PrintErr("%s\n", strerror(errno)); |
Ivan Posva
2013/08/07 18:33:44
ditto
| |
385 char error_message[kBufferSize]; | |
386 strerror_r(errno, error_message, kBufferSize); | |
387 Log::PrintErr("%s\n", error_message); | |
388 } | 385 } |
389 } | 386 } |
390 | 387 |
391 | 388 |
392 bool Socket::SetNonBlocking(intptr_t fd) { | 389 bool Socket::SetNonBlocking(intptr_t fd) { |
393 return FDUtils::SetNonBlocking(fd); | 390 return FDUtils::SetNonBlocking(fd); |
394 } | 391 } |
395 | 392 |
396 | 393 |
397 bool Socket::SetBlocking(intptr_t fd) { | 394 bool Socket::SetBlocking(intptr_t fd) { |
398 return FDUtils::SetBlocking(fd); | 395 return FDUtils::SetBlocking(fd); |
399 } | 396 } |
400 | 397 |
401 | 398 |
402 bool Socket::SetNoDelay(intptr_t fd, bool enabled) { | 399 bool Socket::SetNoDelay(intptr_t fd, bool enabled) { |
403 int on = enabled ? 1 : 0; | 400 int on = enabled ? 1 : 0; |
404 return TEMP_FAILURE_RETRY(setsockopt(fd, | 401 return TEMP_FAILURE_RETRY(setsockopt(fd, |
405 IPPROTO_TCP, | 402 IPPROTO_TCP, |
406 TCP_NODELAY, | 403 TCP_NODELAY, |
407 reinterpret_cast<char *>(&on), | 404 reinterpret_cast<char *>(&on), |
408 sizeof(on))) == 0; | 405 sizeof(on))) == 0; |
409 } | 406 } |
410 | 407 |
411 } // namespace bin | 408 } // namespace bin |
412 } // namespace dart | 409 } // namespace dart |
413 | 410 |
414 #endif // defined(TARGET_OS_LINUX) | 411 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |