You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@apr.apache.org by bu...@apache.org on 2011/04/04 12:48:11 UTC

DO NOT REPLY [Bug 51017] New: apr_file_trunc() fails in buffered mode

https://issues.apache.org/bugzilla/show_bug.cgi?id=51017

           Summary: apr_file_trunc() fails in buffered mode
           Product: APR
           Version: HEAD
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: APR
        AssignedTo: bugs@apr.apache.org
        ReportedBy: carlo.bramix@libero.it


Created an attachment (id=26849)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=26849)
Fix for this bug

After adding support for MinGW+MSys (see also bug #46175), running "make test"
generated this report:

Failed Tests            Total   Fail    Failed %
===================================================
testdso                     5      4     80.00%
testfile                   36      1      2.78%
testpipe                   10      1     10.00%
testsock                   10      1     10.00%
testpass                    4      2     50.00%

I did a quick check on the failure that happens in testfile entry.
This failure happens in test_file_trunc() and it fails to truncate the file
when it is open with APR_FOPEN_BUFFERED flag.
In other words, SetEndOfFile() was never called and obvioulsy the file is never
resized in that state.
I think there is also a bug in use of SetFilePointer API: after its call, we
should test both its return value and the value returned by GetLastError(), for
correct error check with files larger than 4 GB.
I also recommend to work with LARGE_INTEGER type rather than shifting by 32:
gcc complains that, saying that shift by 32 was larger than DWORD type size.

Instead of fixing all places where it is called, I made an internal utility
function "SetFilePointerApr" that should handle the task correctly and it
simplifies a lot the code too.

After applying the fix, "testfile" rised to SUCCESS state.

Sincerely,

Carlo Bramini.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


DO NOT REPLY [Bug 51017] apr_file_trunc() fails in buffered mode

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51017

Carlo Bramini <ca...@libero.it> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #26849|0                           |1
        is obsolete|                            |

--- Comment #2 from Carlo Bramini <ca...@libero.it> 2011-04-04 11:07:30 EDT ---
Created an attachment (id=26850)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=26850)
Fix for this bug

Function name modified according to your suggestion.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


DO NOT REPLY [Bug 51017] apr_file_trunc() fails in buffered mode

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51017

--- Comment #1 from William A. Rowe Jr. <wr...@apache.org> 2011-04-04 10:15:21 EDT ---
Thanks for splitting off this issue!  I haven't gone deeply into your patch,
but just to let you know, our internal conventions would suggest a name like
apr_file_pointer_set[_internal]() or something like that rather than 
SetFilePointerApr... since the later is easily misread as a Windows entry
point.  We don't want the causal reader to become confused when they are
reading the sources :)

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org