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

Side by Side Diff: base/sync_socket_posix.cc

Issue 49303008: Don't use select() in SyncSocket when handle > FD_SETSIZE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/sync_socket.h" 5 #include "base/sync_socket.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <limits.h> 9 #include <limits.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 return 0; 118 return 0;
119 } 119 }
120 120
121 size_t SyncSocket::ReceiveWithTimeout(void* buffer, 121 size_t SyncSocket::ReceiveWithTimeout(void* buffer,
122 size_t length, 122 size_t length,
123 TimeDelta timeout) { 123 TimeDelta timeout) {
124 ThreadRestrictions::AssertIOAllowed(); 124 ThreadRestrictions::AssertIOAllowed();
125 DCHECK_GT(length, 0u); 125 DCHECK_GT(length, 0u);
126 DCHECK_LE(length, kMaxMessageLength); 126 DCHECK_LE(length, kMaxMessageLength);
127 DCHECK_NE(handle_, kInvalidHandle); 127 DCHECK_NE(handle_, kInvalidHandle);
128 CHECK_LT(handle_, FD_SETSIZE); 128
129 // TODO(dalecurtis): There's an undiagnosed issue on OSX where we're seeing
130 // extremely high numbers of open files which prevents select() from being
131 // used. When this is true, the best we can do is Peek() to see if we can
132 // Receive() now and return an error if not. See http://crbug.com/314364.
awong 2013/11/04 23:25:23 Please clarify why returning 0 doesn't turn into d
DaleCurtis 2013/11/04 23:32:25 Clarified that the 0 return value is a timeout err
133 if (handle_ >= FD_SETSIZE)
134 return Peek() < length ? 0 : Receive(buffer, length);
129 135
130 // Only timeouts greater than zero and less than one second are allowed. 136 // Only timeouts greater than zero and less than one second are allowed.
131 DCHECK_GT(timeout.InMicroseconds(), 0); 137 DCHECK_GT(timeout.InMicroseconds(), 0);
132 DCHECK_LT(timeout.InMicroseconds(), 138 DCHECK_LT(timeout.InMicroseconds(),
133 base::TimeDelta::FromSeconds(1).InMicroseconds()); 139 base::TimeDelta::FromSeconds(1).InMicroseconds());
134 140
135 // Track the start time so we can reduce the timeout as data is read. 141 // Track the start time so we can reduce the timeout as data is read.
136 TimeTicks start_time = TimeTicks::Now(); 142 TimeTicks start_time = TimeTicks::Now();
137 const TimeTicks finish_time = start_time + timeout; 143 const TimeTicks finish_time = start_time + timeout;
138 144
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 return len; 223 return len;
218 } 224 }
219 225
220 // static 226 // static
221 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a, 227 bool CancelableSyncSocket::CreatePair(CancelableSyncSocket* socket_a,
222 CancelableSyncSocket* socket_b) { 228 CancelableSyncSocket* socket_b) {
223 return SyncSocket::CreatePair(socket_a, socket_b); 229 return SyncSocket::CreatePair(socket_a, socket_b);
224 } 230 }
225 231
226 } // namespace base 232 } // namespace base
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