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

Unified Diff: tools/android/forwarder2/forwarder.cc

Issue 693943003: Update from https://crrev.com/302630 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « tools/android/forwarder2/device_forwarder_main.cc ('k') | tools/android/forwarder2/forwarder.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/android/forwarder2/forwarder.cc
diff --git a/tools/android/forwarder2/forwarder.cc b/tools/android/forwarder2/forwarder.cc
index 1e0bcd0f53f1aba748b519fdddf0b3364890e98f..8ca25bb2b8e8441b2e34bb3829a9ecd7075d1ed7 100644
--- a/tools/android/forwarder2/forwarder.cc
+++ b/tools/android/forwarder2/forwarder.cc
@@ -25,10 +25,10 @@ const int kBufferSize = 32 * 1024;
//
// These objects are used in a pair to handle duplex traffic, as in:
//
-// ------> [BufferedCopier_1] --->
-// / \
+// -------> [BufferedCopier_1] --->
+// | |
// socket_1 * * socket_2
-// \ /
+// | |
// <------ [BufferedCopier_2] <----
//
// When a BufferedCopier is in the READING state (see below), it only listens
@@ -136,7 +136,13 @@ class Forwarder::BufferedCopier {
// Call this after a select() call to operate over the buffer.
void ProcessSelect(const fd_set& read_fds, const fd_set& write_fds) {
- int fd, ret;
+ int fd;
+ int ret;
+ // With FORTIFY_SOURCE, FD_ISSET is implemented as a function that takes a
+ // non-const fd_set*. Make a copy of the passed arguments so we can safely
+ // take a reference.
+ fd_set read_fds_copy = read_fds;
+ fd_set write_fds_copy = write_fds;
switch (state_) {
case STATE_READING:
fd = socket_from_->fd();
@@ -144,7 +150,7 @@ class Forwarder::BufferedCopier {
state_ = STATE_CLOSED; // T02
return;
}
- if (!FD_ISSET(fd, &read_fds))
+ if (!FD_ISSET(fd, &read_fds_copy))
return;
ret = socket_from_->NonBlockingRead(buffer_, kBufferSize);
@@ -164,7 +170,7 @@ class Forwarder::BufferedCopier {
ForceClose(); // T06 + T11
return;
}
- if (!FD_ISSET(fd, &write_fds))
+ if (!FD_ISSET(fd, &write_fds_copy))
return;
ret = socket_to_->NonBlockingWrite(buffer_ + write_offset_,
« no previous file with comments | « tools/android/forwarder2/device_forwarder_main.cc ('k') | tools/android/forwarder2/forwarder.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698