Closed Bug 397850 Opened 17 years ago Closed 17 years ago

Make NS_ReadLine() not lie about having more data when the stream ends in \r\n

Categories

(Core :: Networking, defect, P3)

x86
Windows XP
defect

Tracking

()

RESOLVED FIXED
mozilla1.9beta3

People

(Reporter: MatsPalmgren_bugz, Assigned: MatsPalmgren_bugz)

Details

(Keywords: perf)

Attachments

(3 files, 1 obsolete file)

Make NS_ReadLine() not lie about having more data when the stream ends in \r\n. Follow up from bug 397768 comment 8. Patch coming up...
Attached patch Patch rev. 1Splinter Review
This is hopefully easier to understand than the old code. I removed "aBuffer->empty" and replaced it with "aBuffer->start == aBuffer->end" as the empty buffer condition and "aBuffer->current" isn't needed between calls so I made it local, and "eolStarted" is redundant since we have "eolchar". It's 2-22% faster than the old code (the lower figure for "normal" content and the higher figure for the edge case of a file filled with \n). It's possible to make the function slightly shorter, by just having one for-loop with the "if (eolchar ...)" tests inside it, but by splitting the loop in two "eolchar" became a loop invariant so it's faster. It's also clearer I think.
Attachment #282971 - Flags: superreview?(cbiesinger)
Attachment #282971 - Flags: review?(cbiesinger)
Attached patch xpcshell regression tests (obsolete) — Splinter Review
Flags: blocking1.9?
Keywords: perf
We want this for bug 410264 ?
Comment on attachment 282972 [details] [diff] [review] xpcshell regression tests should probably make the entries in the test_array strings instead of numbers, because that's what readLine returns can you put your txt files into a data subdirectory of test/unit, so that they don't clutter the directory with the tests?
Attachment #282971 - Flags: superreview?(cbiesinger)
Attachment #282971 - Flags: superreview+
Attachment #282971 - Flags: review?(cbiesinger)
Attachment #282971 - Flags: review+
Flags: blocking1.9? → blocking1.9+
Priority: -- → P3
Did this get resolved?
if there are no objections i'll just land this sometime in the next few days.
Mike, Dan, sorry for the delay. I'm landing some other stuff today so I'll fix Christian's nits and land this today also...
'kLineBufferSize' has been changed from 1024 to 4096 since the last time, so I had to rewrite a few of the tests to trigger the end-of-buffer condition as intended. (I will add a code comment next to the #define to point out that the tests should be updated if the value is changed.) (In reply to comment #4) > should probably make the entries in the test_array strings ... Did so. > can you put your txt files into a data subdirectory of test/unit, That too.
Attachment #282972 - Attachment is obsolete: true
Attached patch Additional patchSplinter Review
There are a couple of uses of the old line buffer fields that I missed, so we need this patch too. Sorry for missing this the first time.
Attachment #296479 - Flags: superreview?(cbiesinger)
Attachment #296479 - Flags: review?(cbiesinger)
Attachment #296479 - Flags: superreview?(cbiesinger)
Attachment #296479 - Flags: superreview+
Attachment #296479 - Flags: review?(cbiesinger)
Attachment #296479 - Flags: review+
I had to do a minor tweak in one of the unit tests for passwordmgr that depended on this bug. Filed bug 412440 on that. mozilla/netwerk/test/unit/test_readline.js 1.1 mozilla/netwerk/test/unit/data/test_readline1.txt 1.1 mozilla/netwerk/test/unit/data/test_readline2.txt 1.1 mozilla/netwerk/test/unit/data/test_readline3.txt 1.1 mozilla/netwerk/test/unit/data/test_readline4.txt 1.1 mozilla/netwerk/test/unit/data/test_readline5.txt 1.1 mozilla/netwerk/test/unit/data/test_readline6.txt 1.1 mozilla/netwerk/test/unit/data/test_readline7.txt 1.1 mozilla/netwerk/test/unit/data/test_readline8.txt 1.1 mozilla/netwerk/base/public/nsReadLine.h 1.12 mozilla/mailnews/compose/src/nsMsgSendPart.cpp 1.64 mozilla/mailnews/local/src/nsLocalMailFolder.cpp 1.568 -> FIXED
Status: NEW → RESOLVED
Closed: 17 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9 M11
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: