Don't read from closed sockets

[ Merge of http://go/wvgerrit/17958 ]

This CL might help diagnose the build bot problem.

b/34261498

Test: All unittests other than some oemcrypto, request_license_test
passed. Those tests failed with or without this CL.

Change-Id: I71e48284b52a1177c6e3b4c9a8bdd12b77cc9f2d
This commit is contained in:
Rahul Frias
2017-01-12 17:41:05 -08:00
parent 8e3206c1be
commit 41ba5aa745

View File

@@ -297,6 +297,10 @@ int HttpSocket::Read(char* data, int len, int timeout_in_ms) {
int total_read = 0;
int to_read = len;
if (socket_fd_ == -1) {
LOGE("Socket to %s not open. Cannot read.", domain_name_.c_str());
return -1;
}
while (to_read > 0) {
if (!SocketWait(socket_fd_, /* for_read */ true, timeout_in_ms)) {
LOGE("unable to read from %s", domain_name_.c_str());
@@ -332,6 +336,10 @@ int HttpSocket::Write(const char* data, int len, int timeout_in_ms) {
int total_sent = 0;
int to_send = len;
if (socket_fd_ == -1) {
LOGE("Socket to %s not open. Cannot write.", domain_name_.c_str());
return -1;
}
while (to_send > 0) {
int sent;
if (secure_connect_)