Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(599)

Side by Side Diff: net/socket/tcp_client_socket_win.cc

Issue 8083031: TcpClientSocketWin may detect EOF before the last asynchronous I/O (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: checking just waiting_read_ is sufficient Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_win.h" 5 #include "net/socket/tcp_client_socket_win.h"
6 6
7 #include <mstcpip.h> 7 #include <mstcpip.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 582
583 previously_disconnected_ = true; 583 previously_disconnected_ = true;
584 } 584 }
585 585
586 bool TCPClientSocketWin::IsConnected() const { 586 bool TCPClientSocketWin::IsConnected() const {
587 DCHECK(CalledOnValidThread()); 587 DCHECK(CalledOnValidThread());
588 588
589 if (socket_ == INVALID_SOCKET || waiting_connect()) 589 if (socket_ == INVALID_SOCKET || waiting_connect())
590 return false; 590 return false;
591 591
592 if (waiting_read_)
593 return true;
594
592 // Check if connection is alive. 595 // Check if connection is alive.
593 char c; 596 char c;
594 int rv = recv(socket_, &c, 1, MSG_PEEK); 597 int rv = recv(socket_, &c, 1, MSG_PEEK);
595 if (rv == 0) 598 if (rv == 0)
596 return false; 599 return false;
597 if (rv == SOCKET_ERROR && WSAGetLastError() != WSAEWOULDBLOCK) 600 if (rv == SOCKET_ERROR && WSAGetLastError() != WSAEWOULDBLOCK)
598 return false; 601 return false;
599 602
600 return true; 603 return true;
601 } 604 }
602 605
603 bool TCPClientSocketWin::IsConnectedAndIdle() const { 606 bool TCPClientSocketWin::IsConnectedAndIdle() const {
604 DCHECK(CalledOnValidThread()); 607 DCHECK(CalledOnValidThread());
605 608
606 if (socket_ == INVALID_SOCKET || waiting_connect()) 609 if (socket_ == INVALID_SOCKET || waiting_connect())
607 return false; 610 return false;
608 611
612 if (waiting_read_)
613 return true;
614
609 // Check if connection is alive and we haven't received any data 615 // Check if connection is alive and we haven't received any data
610 // unexpectedly. 616 // unexpectedly.
611 char c; 617 char c;
612 int rv = recv(socket_, &c, 1, MSG_PEEK); 618 int rv = recv(socket_, &c, 1, MSG_PEEK);
613 if (rv >= 0) 619 if (rv >= 0)
614 return false; 620 return false;
615 if (WSAGetLastError() != WSAEWOULDBLOCK) 621 if (WSAGetLastError() != WSAEWOULDBLOCK)
616 return false; 622 return false;
617 623
618 return true; 624 return true;
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 use_history_.set_was_used_to_convey_data(); 904 use_history_.set_was_used_to_convey_data();
899 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_SENT, num_bytes, 905 net_log_.AddByteTransferEvent(NetLog::TYPE_SOCKET_BYTES_SENT, num_bytes,
900 core_->write_buffer_.buf); 906 core_->write_buffer_.buf);
901 } 907 }
902 } 908 }
903 core_->write_iobuffer_ = NULL; 909 core_->write_iobuffer_ = NULL;
904 DoWriteCallback(rv); 910 DoWriteCallback(rv);
905 } 911 }
906 912
907 } // namespace net 913 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698