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

Issue 23875019: Add SyncSocket::ReceiveWithTimeout() and SyncSocket unit tests. (Closed)

Created:
7 years, 3 months ago by DaleCurtis
Modified:
7 years, 2 months ago
CC:
chromium-reviews, erikwright+watch_chromium.org, awong, Nico
Visibility:
Public.

Description

Add SyncSocket::ReceiveWithTimeout() and SyncSocket unit tests. Method does as advertised using select() on POSIX and the existing CancelableFileOperation() wrapper on Windows since there is no select() equivalent on XP. It was also high time we had some unit tests for this class, so I added a small set which exercise almost the full functionality. BUG=289124 TEST=base_unittests! Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=229621

Patch Set 1 #

Total comments: 9

Patch Set 2 : Remove DCHECK. #

Patch Set 3 : Add comments. #

Patch Set 4 : Only read Peek() bytes. #

Total comments: 4

Patch Set 5 : Fixes. #

Total comments: 23

Patch Set 6 : Nits, nits everywhere! #

Patch Set 7 : Handle EINTR. Reverse expectations. #

Total comments: 15

Patch Set 8 : Fix timeout and naming. #

Total comments: 12

Patch Set 9 : Explicitly check microseconds. #

Total comments: 2

Patch Set 10 : Revert NaCl changes. #

Patch Set 11 : Consts. #

Total comments: 2

Patch Set 12 : Nits. #

Patch Set 13 : static_cast<suseconds_t> #

Patch Set 14 : Only AssertIOAllowed() on blocking Send(). #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+321 lines, -56 lines) Patch
M base/base.gyp View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +1 line, -0 lines 0 comments Download
M base/sync_socket.h View 1 2 3 4 5 6 7 8 3 chunks +11 lines, -0 lines 0 comments Download
M base/sync_socket_nacl.cc View 1 2 3 4 5 6 7 8 9 1 chunk +5 lines, -0 lines 0 comments Download
M base/sync_socket_posix.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 6 chunks +97 lines, -24 lines 3 comments Download
A base/sync_socket_unittest.cc View 1 2 3 4 5 6 7 1 chunk +131 lines, -0 lines 0 comments Download
M base/sync_socket_win.cc View 1 2 3 4 5 6 7 8 9 10 11 9 chunks +76 lines, -32 lines 0 comments Download

Messages

Total messages: 50 (0 generated)
DaleCurtis
Split off of https://codereview.chromium.org/22886005/
7 years, 3 months ago (2013-09-11 01:09:52 UTC) #1
tommi (sloooow) - chröme
lgtm
7 years, 3 months ago (2013-09-11 20:25:52 UTC) #2
awong
https://codereview.chromium.org/23875019/diff/1/base/sync_socket_posix.cc File base/sync_socket_posix.cc (right): https://codereview.chromium.org/23875019/diff/1/base/sync_socket_posix.cc#newcode118 base/sync_socket_posix.cc:118: DCHECK(timeout.InMicroseconds() < Time::kMicrosecondsPerSecond); nit: DCHECK_LT? https://codereview.chromium.org/23875019/diff/1/base/sync_socket_posix.cc#newcode126 base/sync_socket_posix.cc:126: DCHECK_GE(Peek(), length); ...
7 years, 3 months ago (2013-09-17 18:54:12 UTC) #3
awong
https://codereview.chromium.org/23875019/diff/1/base/sync_socket_unittest.cc File base/sync_socket_unittest.cc (right): https://codereview.chromium.org/23875019/diff/1/base/sync_socket_unittest.cc#newcode53 base/sync_socket_unittest.cc:53: ASSERT_EQ(a->Peek(), 0u); ASSERT_EQ just exists the current function. Is ...
7 years, 3 months ago (2013-09-17 18:56:59 UTC) #4
DaleCurtis
https://codereview.chromium.org/23875019/diff/1/base/sync_socket_posix.cc File base/sync_socket_posix.cc (right): https://codereview.chromium.org/23875019/diff/1/base/sync_socket_posix.cc#newcode118 base/sync_socket_posix.cc:118: DCHECK(timeout.InMicroseconds() < Time::kMicrosecondsPerSecond); On 2013/09/17 18:54:12, awong wrote: > ...
7 years, 3 months ago (2013-09-17 19:00:24 UTC) #5
DaleCurtis
https://codereview.chromium.org/23875019/diff/1/base/sync_socket_unittest.cc File base/sync_socket_unittest.cc (right): https://codereview.chromium.org/23875019/diff/1/base/sync_socket_unittest.cc#newcode53 base/sync_socket_unittest.cc:53: ASSERT_EQ(a->Peek(), 0u); On 2013/09/17 18:57:00, awong wrote: > ASSERT_EQ ...
7 years, 3 months ago (2013-09-17 19:36:27 UTC) #6
awong
Latest patchset seems corrupted. Could you reupload? On Tue, Sep 17, 2013 at 12:00 PM, ...
7 years, 3 months ago (2013-09-17 19:45:57 UTC) #7
DaleCurtis
Whoops, reuploaded.
7 years, 3 months ago (2013-09-17 19:47:35 UTC) #8
awong
https://codereview.chromium.org/23875019/diff/1/base/sync_socket_posix.cc File base/sync_socket_posix.cc (right): https://codereview.chromium.org/23875019/diff/1/base/sync_socket_posix.cc#newcode118 base/sync_socket_posix.cc:118: DCHECK(timeout.InMicroseconds() < Time::kMicrosecondsPerSecond); On 2013/09/17 19:00:25, DaleCurtis wrote: > ...
7 years, 3 months ago (2013-09-17 19:57:10 UTC) #9
DaleCurtis
https://codereview.chromium.org/23875019/diff/1/base/sync_socket_posix.cc File base/sync_socket_posix.cc (right): https://codereview.chromium.org/23875019/diff/1/base/sync_socket_posix.cc#newcode126 base/sync_socket_posix.cc:126: DCHECK_GE(Peek(), length); On 2013/09/17 19:57:11, awong wrote: > On ...
7 years, 3 months ago (2013-09-17 20:13:44 UTC) #10
DaleCurtis
PTAL. This version only reads the amount returned by Peek() per our offline conversation. https://codereview.chromium.org/23875019/diff/25001/base/sync_socket_posix.cc ...
7 years, 2 months ago (2013-09-25 22:48:25 UTC) #11
tommi (sloooow) - chröme
https://codereview.chromium.org/23875019/diff/25001/base/sync_socket_posix.cc File base/sync_socket_posix.cc (right): https://codereview.chromium.org/23875019/diff/25001/base/sync_socket_posix.cc#newcode176 base/sync_socket_posix.cc:176: long flags = 0; On 2013/09/25 22:48:25, DaleCurtis wrote: ...
7 years, 2 months ago (2013-09-29 09:15:54 UTC) #12
DaleCurtis
https://codereview.chromium.org/23875019/diff/25001/base/sync_socket_posix.cc File base/sync_socket_posix.cc (right): https://codereview.chromium.org/23875019/diff/25001/base/sync_socket_posix.cc#newcode176 base/sync_socket_posix.cc:176: long flags = 0; On 2013/09/29 09:15:54, tommi wrote: ...
7 years, 2 months ago (2013-09-30 18:00:51 UTC) #13
DaleCurtis
Oh and hah, I found the sync socket unit tests... in ipc/ https://code.google.com/p/chromium/codesearch#chromium/src/ipc/sync_socket_unittest.cc Which does ...
7 years, 2 months ago (2013-09-30 18:03:36 UTC) #14
tommi (sloooow) - chröme
Oh, sorry I should have told you that :-/ I think we shouldn't throw the ...
7 years, 2 months ago (2013-09-30 19:43:34 UTC) #15
DaleCurtis
awong is heading for vacation, so cc:ajwong, +thakis for OWNERS review.
7 years, 2 months ago (2013-09-30 23:18:24 UTC) #16
Nico
I think willchan (posix) and jar (windows) are better reviewers for this than I. https://codereview.chromium.org/23875019/diff/36001/base/sync_socket_posix.cc ...
7 years, 2 months ago (2013-10-04 05:35:11 UTC) #17
willchan no longer on Chromium
https://codereview.chromium.org/23875019/diff/36001/base/sync_socket.h File base/sync_socket.h (right): https://codereview.chromium.org/23875019/diff/36001/base/sync_socket.h#newcode58 base/sync_socket.h:58: // length is the number of bytes of data ...
7 years, 2 months ago (2013-10-04 21:01:34 UTC) #18
DaleCurtis
(Just comments) https://codereview.chromium.org/23875019/diff/36001/base/sync_socket_posix.cc File base/sync_socket_posix.cc (right): https://codereview.chromium.org/23875019/diff/36001/base/sync_socket_posix.cc#newcode114 base/sync_socket_posix.cc:114: TimeDelta timeout) { On 2013/10/04 21:01:35, willchan ...
7 years, 2 months ago (2013-10-04 21:08:38 UTC) #19
DaleCurtis
This patch set also fixes a number of style nits and potential bugs that we ...
7 years, 2 months ago (2013-10-04 23:11:32 UTC) #20
DaleCurtis
willchan: ping?
7 years, 2 months ago (2013-10-08 18:09:56 UTC) #21
willchan no longer on Chromium
Part-time + conference => very little review bandwidth. I'll try to wrap this up today ...
7 years, 2 months ago (2013-10-08 20:28:13 UTC) #22
willchan no longer on Chromium
I'm going to hand off the approval to jar@ since he needs to review the ...
7 years, 2 months ago (2013-10-09 20:06:52 UTC) #23
DaleCurtis
Thanks for the review. Patch updated. https://codereview.chromium.org/23875019/diff/36001/base/sync_socket_posix.cc File base/sync_socket_posix.cc (right): https://codereview.chromium.org/23875019/diff/36001/base/sync_socket_posix.cc#newcode134 base/sync_socket_posix.cc:134: const int select_result ...
7 years, 2 months ago (2013-10-09 21:55:40 UTC) #24
jar (doing other things)
I probably need to re-read this more carefully, but the loop constraints for the timeout ...
7 years, 2 months ago (2013-10-10 02:01:27 UTC) #25
DaleCurtis
(no updates, just comments) https://codereview.chromium.org/23875019/diff/69001/base/sync_socket_posix.cc File base/sync_socket_posix.cc (right): https://codereview.chromium.org/23875019/diff/69001/base/sync_socket_posix.cc#newcode86 base/sync_socket_posix.cc:86: return true; On 2013/10/10 02:01:28, ...
7 years, 2 months ago (2013-10-10 17:37:34 UTC) #26
jar (doing other things)
https://codereview.chromium.org/23875019/diff/69001/base/sync_socket_posix.cc File base/sync_socket_posix.cc (right): https://codereview.chromium.org/23875019/diff/69001/base/sync_socket_posix.cc#newcode162 base/sync_socket_posix.cc:162: (timeout -= (TimeTicks::Now() - start_time)) > TimeDelta()); On 2013/10/10 ...
7 years, 2 months ago (2013-10-11 02:36:11 UTC) #27
DaleCurtis
Thanks for your review. Patch updated. https://codereview.chromium.org/23875019/diff/69001/base/sync_socket_posix.cc File base/sync_socket_posix.cc (right): https://codereview.chromium.org/23875019/diff/69001/base/sync_socket_posix.cc#newcode121 base/sync_socket_posix.cc:121: DCHECK_LT(handle_, FD_SETSIZE); I ...
7 years, 2 months ago (2013-10-11 22:48:24 UTC) #28
jar (doing other things)
https://codereview.chromium.org/23875019/diff/83001/base/sync_socket.h File base/sync_socket.h (right): https://codereview.chromium.org/23875019/diff/83001/base/sync_socket.h#newcode62 base/sync_socket.h:62: // Same as Receive() but only blocks for data ...
7 years, 2 months ago (2013-10-14 15:31:07 UTC) #29
DaleCurtis
PTAL. https://codereview.chromium.org/23875019/diff/83001/base/sync_socket.h File base/sync_socket.h (right): https://codereview.chromium.org/23875019/diff/83001/base/sync_socket.h#newcode62 base/sync_socket.h:62: // Same as Receive() but only blocks for ...
7 years, 2 months ago (2013-10-14 19:25:13 UTC) #30
jar (doing other things)
https://codereview.chromium.org/23875019/diff/98001/base/sync_socket_nacl.cc File base/sync_socket_nacl.cc (right): https://codereview.chromium.org/23875019/diff/98001/base/sync_socket_nacl.cc#newcode51 base/sync_socket_nacl.cc:51: return 0; When I argued for returning 0 (not ...
7 years, 2 months ago (2013-10-14 22:49:17 UTC) #31
DaleCurtis
https://codereview.chromium.org/23875019/diff/98001/base/sync_socket_nacl.cc File base/sync_socket_nacl.cc (right): https://codereview.chromium.org/23875019/diff/98001/base/sync_socket_nacl.cc#newcode51 base/sync_socket_nacl.cc:51: return 0; On 2013/10/14 22:49:18, jar wrote: > When ...
7 years, 2 months ago (2013-10-14 23:12:33 UTC) #32
jar (doing other things)
On 2013/10/14 23:12:33, DaleCurtis wrote: > https://codereview.chromium.org/23875019/diff/98001/base/sync_socket_nacl.cc > File base/sync_socket_nacl.cc (right): > > https://codereview.chromium.org/23875019/diff/98001/base/sync_socket_nacl.cc#newcode51 > ...
7 years, 2 months ago (2013-10-14 23:16:53 UTC) #33
DaleCurtis
Done.
7 years, 2 months ago (2013-10-14 23:19:22 UTC) #34
DaleCurtis
jar: Any other comments for this CL? The NaCl changes depend on this.
7 years, 2 months ago (2013-10-15 20:16:36 UTC) #35
jar (doing other things)
LGTM % nit https://codereview.chromium.org/23875019/diff/113001/base/sync_socket_win.cc File base/sync_socket_win.cc (right): https://codereview.chromium.org/23875019/diff/113001/base/sync_socket_win.cc#newcode114 base/sync_socket_win.cc:114: size_t CancelableFileOperation(Function operation, HANDLE file, nit: ...
7 years, 2 months ago (2013-10-15 21:13:59 UTC) #36
DaleCurtis
https://codereview.chromium.org/23875019/diff/113001/base/sync_socket_win.cc File base/sync_socket_win.cc (right): https://codereview.chromium.org/23875019/diff/113001/base/sync_socket_win.cc#newcode114 base/sync_socket_win.cc:114: size_t CancelableFileOperation(Function operation, HANDLE file, On 2013/10/15 21:14:00, jar ...
7 years, 2 months ago (2013-10-15 22:06:48 UTC) #37
DaleCurtis
Thanks for the review!
7 years, 2 months ago (2013-10-15 22:07:01 UTC) #38
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/dalecurtis@chromium.org/23875019/118001
7 years, 2 months ago (2013-10-15 22:11:38 UTC) #39
commit-bot: I haz the power
Sorry for I got bad news for ya. Compile failed with a clobber build on ...
7 years, 2 months ago (2013-10-15 22:59:01 UTC) #40
DaleCurtis
The ThreadRestrictions::AssertIORequired() changes require this bug fix to land first: https://codereview.chromium.org/26687007/
7 years, 2 months ago (2013-10-16 00:41:44 UTC) #41
DaleCurtis
Actually, a small change was necessary to keep the AssertIOAllowed calls. I've moved the SyncSocket::Send() ...
7 years, 2 months ago (2013-10-17 20:18:00 UTC) #42
jar (doing other things)
Patch set 14 still LGTM. One small thought below, that you can take or leave. ...
7 years, 2 months ago (2013-10-18 22:02:51 UTC) #43
DaleCurtis
https://codereview.chromium.org/23875019/diff/140007/base/sync_socket_posix.cc File base/sync_socket_posix.cc (right): https://codereview.chromium.org/23875019/diff/140007/base/sync_socket_posix.cc#newcode143 base/sync_socket_posix.cc:143: bytes_read_total < length && timeout.InMicroseconds() > 0; On 2013/10/18 ...
7 years, 2 months ago (2013-10-18 22:10:49 UTC) #44
jar (doing other things)
LGTM https://codereview.chromium.org/23875019/diff/140007/base/sync_socket_posix.cc File base/sync_socket_posix.cc (right): https://codereview.chromium.org/23875019/diff/140007/base/sync_socket_posix.cc#newcode143 base/sync_socket_posix.cc:143: bytes_read_total < length && timeout.InMicroseconds() > 0; On ...
7 years, 2 months ago (2013-10-18 22:29:57 UTC) #45
DaleCurtis
Thanks again for the reviews!
7 years, 2 months ago (2013-10-18 22:37:05 UTC) #46
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/dalecurtis@chromium.org/23875019/140007
7 years, 2 months ago (2013-10-18 22:49:43 UTC) #47
commit-bot: I haz the power
Retried try job too often on win_rel for step(s) content_browsertests http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=win_rel&number=211006
7 years, 2 months ago (2013-10-19 02:06:41 UTC) #48
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/dalecurtis@chromium.org/23875019/140007
7 years, 2 months ago (2013-10-19 20:02:51 UTC) #49
commit-bot: I haz the power
7 years, 2 months ago (2013-10-19 22:13:21 UTC) #50
Message was sent while issue was closed.
Change committed as 229621

Powered by Google App Engine
This is Rietveld 408576698