OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/sync_socket.h" | 5 #include "base/sync_socket.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <limits.h> | 9 #include <limits.h> |
10 #include <stddef.h> | 10 #include <stddef.h> |
(...skipping 27 matching lines...) Expand all Loading... |
38 DCHECK_LE(length, kMaxMessageLength); | 38 DCHECK_LE(length, kMaxMessageLength); |
39 DCHECK_NE(handle, SyncSocket::kInvalidHandle); | 39 DCHECK_NE(handle, SyncSocket::kInvalidHandle); |
40 const char* charbuffer = static_cast<const char*>(buffer); | 40 const char* charbuffer = static_cast<const char*>(buffer); |
41 return WriteFileDescriptor(handle, charbuffer, length) | 41 return WriteFileDescriptor(handle, charbuffer, length) |
42 ? static_cast<size_t>(length) | 42 ? static_cast<size_t>(length) |
43 : 0; | 43 : 0; |
44 } | 44 } |
45 | 45 |
46 bool CloseHandle(SyncSocket::Handle handle) { | 46 bool CloseHandle(SyncSocket::Handle handle) { |
47 if (handle != SyncSocket::kInvalidHandle && close(handle) < 0) { | 47 if (handle != SyncSocket::kInvalidHandle && close(handle) < 0) { |
| 48 CHECK(errno != EBADF) << "Probable double-close of socket handle."; |
48 DPLOG(ERROR) << "close"; | 49 DPLOG(ERROR) << "close"; |
49 return false; | 50 return false; |
50 } | 51 } |
51 | 52 |
52 return true; | 53 return true; |
53 } | 54 } |
54 | 55 |
55 } // namespace | 56 } // namespace |
56 | 57 |
57 const SyncSocket::Handle SyncSocket::kInvalidHandle = -1; | 58 const SyncSocket::Handle SyncSocket::kInvalidHandle = -1; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 return len; | 246 return len; |
246 } | 247 } |
247 | 248 |
248 // static | 249 // static |
249 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, | 250 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, |
250 CancelableSyncSocket* socket_b) { | 251 CancelableSyncSocket* socket_b) { |
251 return SyncSocket::CreatePair(socket_a, socket_b); | 252 return SyncSocket::CreatePair(socket_a, socket_b); |
252 } | 253 } |
253 | 254 |
254 } // namespace base | 255 } // namespace base |
OLD | NEW |