Closed
Bug 39011
Opened 24 years ago
Closed 24 years ago
Problems with ssl_EmulateSendFile
Categories
(NSS :: Libraries, defect, P3)
Tracking
(Not tracked)
VERIFIED
FIXED
People
(Reporter: wtc, Assigned: nelson)
Details
Attachments
(1 file)
1011 bytes,
patch
|
Details | Diff | Splinter Review |
mozilla/security/nss/lib/ssl/emulate.c, revision 1.1 Function ssl_EmulateSendFile 1. The alignment of the offset argument to PR_MemMap is not the page size on Windows. (See bug #38896.) On Windows you need to call GetSystemInfo() and align the offset to the "allocation granularity". 2. The size argument to PR_CreateFileMap should be 0 or file size (info.size). 3. Strictly speaking, you need to pass 64-bit integers to PR_CreateFileMap and PR_MemMap as the second argument. ssl_EmulateTransmitFile doesn't have problems 1 and 2 (assuming TRANSMITFILE_MMAP_CHUNK, 256K, meets the alignment requirement on all platforms).
Reporter | ||
Comment 1•24 years ago
|
||
Assignee | ||
Comment 2•24 years ago
|
||
Wan-Teh, 1. Bug 38896 doesn't seem to have anything to do with this. I suspect you meant to cite a different bug, but don't know which one. Which one was it? 2. I object to having to make an OS-dependent call in order to use NSPR's memory mapping. It seems to defeat the whole purpose of having a "portable" runtime API. I guess I'm saying I think there needs to be an NSPR function that returns the mem mapping alignment boundary. 3. The code in ssl_EmulateSendFile, which was copied more-or-less out of NSPR, depends on pagesize being a power of 2, and generates incorrect results if it is not. Are we guaranteed that it is always a power of two on Windows? 4. What does a zero size mean, exactly, for PR_CreateFileMap? 5. If the only valid values for size are 0 (which I gather implicitly means the size of the file), or the size of the file, then what purpose does this argument serve? Isn't the size argument unnecessary? 5. Does passing 0 for the size argument in PR_CreateFileMap work on all platforms?
Assignee | ||
Comment 3•24 years ago
|
||
emulate.c rev 1.2 contains more-or-less the changes you suggested. I passed info.size, rather than zero, for the file size argument to PR_CreateFileMap.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Reporter | ||
Comment 4•24 years ago
|
||
1. The related bug that I meant to cite should be bug #38996, "New function PR_GetMemMapAlignment". 2. The reason my patch (id=8574) has to make an OS-dependent call is that NSPR 4.0 and earlier incorrectly assume that the mem mapping alignment boundary is the page size. To work around this NSPR bug, you have to make an OS-dependent call. When you upgrade to NSPR 4.1 you will be able to call the new function PR_GetMemMapAlignment() instead. (But you might as well use the new PR_EmulateSendFile function in NSPR 4.1 directly.) 3. I'm not sure if any OS guarantees that the page size or rather mem mapping alignment boundary is a power of 2. I think any sane OS designer will use a power of 2 to make certain operations faster. We can certainly replace the & operations (which rely on the mem mapping alignment boundary being a power of 2) with / and % operations. 4,5,6. The size argument to PR_CreateFileMap causes the underlying file to be extended if it is larger than the current size. In the current implementation, a size argument of 0 means the current file size, however this behavior is not documented so it's a good idea to just pass the current file size to PR_CreateFileMap.
Reporter | ||
Comment 5•24 years ago
|
||
You might want to convert info.size to a PRInt64 and pass the PRInt64 as the second argument to PR_CreateFileMap.
Assignee | ||
Comment 6•24 years ago
|
||
Why? Given that the function is prototyped, and the argument is typed in the prototype, ANSI c guarantees that the correct conversion will be implicitly supplied. What value is there in explicitly supplying it?
Reporter | ||
Comment 7•24 years ago
|
||
PRInt64 is defined as a struct on platforms without a 64-bit integer type.
Assignee | ||
Comment 8•24 years ago
|
||
Do we actually support any such platforms any more? Wasn't Win16 the last one?
Reporter | ||
Comment 9•24 years ago
|
||
Since that code is ifdef's with WIN32 and XP_UNIX, this could only break under older Unix compilers. The recent Unix compilers and gcc all support a 64-bit integer type. I just tend to be more conservative.
Comment 10•24 years ago
|
||
Verified per wtc's comments.
Status: RESOLVED → VERIFIED
QA Contact: lord → junruh
You need to log in
before you can comment on or make changes to this bug.
Description
•