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

Unified Diff: remoting/host/security_key/security_key_socket.cc

Issue 2589933002: Updating SecurityKeyAuthHandlerPosix socket lifetime management (Closed)
Patch Set: Addressing CR feedback Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/security_key/security_key_socket.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/security_key/security_key_socket.cc
diff --git a/remoting/host/security_key/security_key_socket.cc b/remoting/host/security_key/security_key_socket.cc
index 88239ad4008d4bdd0d812dab8c0cd9eb4a70d6b6..569e53cf12e4d9430e7fdfd8134d936ef5a6613e 100644
--- a/remoting/host/security_key/security_key_socket.cc
+++ b/remoting/host/security_key/security_key_socket.cc
@@ -30,7 +30,6 @@ SecurityKeySocket::SecurityKeySocket(std::unique_ptr<net::StreamSocket> socket,
base::TimeDelta timeout,
const base::Closure& timeout_callback)
: socket_(std::move(socket)),
- read_completed_(false),
read_buffer_(new net::IOBufferWithSize(kRequestReadBufferLength)) {
timer_.reset(new base::Timer(false, false));
timer_->Start(FROM_HERE, timeout, timeout_callback);
@@ -40,11 +39,8 @@ SecurityKeySocket::~SecurityKeySocket() {}
bool SecurityKeySocket::GetAndClearRequestData(std::string* data_out) {
DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(read_completed_);
+ DCHECK(!waiting_for_request_);
- if (!read_completed_) {
- return false;
- }
if (!IsRequestComplete() || IsRequestTooLarge()) {
return false;
}
@@ -81,7 +77,9 @@ void SecurityKeySocket::StartReadingRequest(
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(request_received_callback_.is_null());
+ waiting_for_request_ = true;
request_received_callback_ = request_received_callback;
+
DoRead();
}
@@ -122,17 +120,22 @@ void SecurityKeySocket::OnDataRead(int result) {
if (result <= 0) {
if (result < 0) {
LOG(ERROR) << "Error reading request: " << result;
+ socket_read_error_ = true;
}
- read_completed_ = true;
+ waiting_for_request_ = false;
base::ResetAndReturn(&request_received_callback_).Run();
return;
}
ResetTimer();
+ // TODO(joedow): If there are multiple requests in a burst, it is possible
+ // that we could read too many bytes from the buffer (e.g. all of request #1
+ // and some of request #2). We should consider using the request header to
+ // determine the request length and only read that amount from buffer.
Sergey Ulanov 2016/12/20 00:54:23 I think it would be easier to keep the current rea
joedow 2016/12/20 02:24:03 That's reasonable. I'll work on that tomorrow and
request_data_.insert(request_data_.end(), read_buffer_->data(),
read_buffer_->data() + result);
if (IsRequestComplete()) {
- read_completed_ = true;
+ waiting_for_request_ = false;
base::ResetAndReturn(&request_received_callback_).Run();
return;
}
« no previous file with comments | « remoting/host/security_key/security_key_socket.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698