Review Request 108380: Fix race condition in KTcpSocketTest

Jon Severinsson jon at severinsson.net
Sun Jan 13 11:52:46 UTC 2013



> On Jan. 13, 2013, 10:58 a.m., David Faure wrote:
> > kdecore/tests/ktcpsockettest.cpp, line 237
> > <http://git.reviewboard.kde.org/r/108380/diff/1/?file=106979#file106979line237>
> >
> >     The 1111 relies on the current content of the page being fetched? :-)
> >     
> >     If hardcoding the data size in the test can't be avoided, maybe we should upload a test file on a kde server instead of relying on www.iana.org's front page...

It's actually IANA's www.example.com page, which the test assumes will be hosted on the same IP address as www.iana.org forever, and never shrink.

That said, the while loop is currently unnecessary and only a remnant of an earlier attempt to get the test working with two requests, will drop it.


> On Jan. 13, 2013, 10:58 a.m., David Faure wrote:
> > kdecore/tests/ktcpsockettest.cpp, line 240
> > <http://git.reviewboard.kde.org/r/108380/diff/1/?file=106979#file106979line240>
> >
> >     I'm not sure why the test was making the HTTP Request twice (Andreas?), but this is changing what's actually being tested, a little bit, I think?
> >

Yes, it changes what is tested, because the only way to correctly perform the original test is to wait for the full first response to arrive before making the second request, which would require either knowing the exact response size, or doing full HTTP parsing (and assume that the response will contain a valid Content-Length: header). So I changed the test to only test for what the code comments indicated should be tested for...


- Jon


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/108380/#review25346
-----------------------------------------------------------


On Jan. 13, 2013, 9:28 a.m., Jon Severinsson wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/108380/
> -----------------------------------------------------------
> 
> (Updated Jan. 13, 2013, 9:28 a.m.)
> 
> 
> Review request for KDE Frameworks and kdelibs.
> 
> 
> Description
> -------
> 
> In some cases, only part of the first response had arrived when the second
> s->write(HTTPREQUEST) was executed. Thus the second s->waitForReadyRead()
> would return when the rest of the first response arrived, which in some
> cases would be before the second request had left the write buffer
> That in turn meant that s->close() would be run with a non-empty write
> buffer, thus only putting the socket in ClosingState rather than
> UnconnectedState as the test expected.
> 
> Only tested on the frameworks branch, but it might be applicable to master as well.
> 
> 
> Diffs
> -----
> 
>   kdecore/tests/ktcpsockettest.cpp bfc4212 
> 
> Diff: http://git.reviewboard.kde.org/r/108380/diff/
> 
> 
> Testing
> -------
> 
> Run the test 100 times in a loop without any failures.
> 
> 
> Thanks,
> 
> Jon Severinsson
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20130113/6296ed54/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list