From 41ba5aa745015f85e034481fada7abc1ded121c0 Mon Sep 17 00:00:00 2001 From: Rahul Frias Date: Thu, 12 Jan 2017 17:41:05 -0800 Subject: [PATCH] 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 --- libwvdrmengine/cdm/core/test/http_socket.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libwvdrmengine/cdm/core/test/http_socket.cpp b/libwvdrmengine/cdm/core/test/http_socket.cpp index 10a4abb1..f1d20daf 100644 --- a/libwvdrmengine/cdm/core/test/http_socket.cpp +++ b/libwvdrmengine/cdm/core/test/http_socket.cpp @@ -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_)