| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "net/socket/tcp_client_socket_libevent.h" | 5 #include "net/socket/tcp_client_socket_libevent.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <netdb.h> | 9 #include <netdb.h> |
| 10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 } | 249 } |
| 250 | 250 |
| 251 void TCPClientSocketLibevent::DoDisconnect() { | 251 void TCPClientSocketLibevent::DoDisconnect() { |
| 252 if (socket_ == kInvalidSocket) | 252 if (socket_ == kInvalidSocket) |
| 253 return; | 253 return; |
| 254 | 254 |
| 255 bool ok = read_socket_watcher_.StopWatchingFileDescriptor(); | 255 bool ok = read_socket_watcher_.StopWatchingFileDescriptor(); |
| 256 DCHECK(ok); | 256 DCHECK(ok); |
| 257 ok = write_socket_watcher_.StopWatchingFileDescriptor(); | 257 ok = write_socket_watcher_.StopWatchingFileDescriptor(); |
| 258 DCHECK(ok); | 258 DCHECK(ok); |
| 259 HANDLE_EINTR(close(socket_)); | 259 if (HANDLE_EINTR(close(socket_)) < 0) |
| 260 PLOG(ERROR) << "close"; |
| 260 socket_ = kInvalidSocket; | 261 socket_ = kInvalidSocket; |
| 261 } | 262 } |
| 262 | 263 |
| 263 bool TCPClientSocketLibevent::IsConnected() const { | 264 bool TCPClientSocketLibevent::IsConnected() const { |
| 264 DCHECK(CalledOnValidThread()); | 265 DCHECK(CalledOnValidThread()); |
| 265 | 266 |
| 266 if (socket_ == kInvalidSocket || waiting_connect()) | 267 if (socket_ == kInvalidSocket || waiting_connect()) |
| 267 return false; | 268 return false; |
| 268 | 269 |
| 269 // Check if connection is alive. | 270 // Check if connection is alive. |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 int TCPClientSocketLibevent::GetPeerAddress(AddressList* address) const { | 500 int TCPClientSocketLibevent::GetPeerAddress(AddressList* address) const { |
| 500 DCHECK(CalledOnValidThread()); | 501 DCHECK(CalledOnValidThread()); |
| 501 DCHECK(address); | 502 DCHECK(address); |
| 502 if (!current_ai_) | 503 if (!current_ai_) |
| 503 return ERR_UNEXPECTED; | 504 return ERR_UNEXPECTED; |
| 504 address->Copy(current_ai_, false); | 505 address->Copy(current_ai_, false); |
| 505 return OK; | 506 return OK; |
| 506 } | 507 } |
| 507 | 508 |
| 508 } // namespace net | 509 } // namespace net |
| OLD | NEW |