You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by ro...@apache.org on 2006/01/30 07:55:11 UTC
svn commit: r373454 - in /apr/apr/branches/1.2.x: CHANGES
file_io/win32/seek.c test/testfile.c
Author: rooneg
Date: Sun Jan 29 22:55:09 2006
New Revision: 373454
URL: http://svn.apache.org/viewcvs?rev=373454&view=rev
Log:
Merge r373453 into 1.2.x.
Original log message:
Fix bug #38438, seeks are broken for files opened for append in xthread
mode on win32.
Submitted by: M Joonas Pihlaja <jpihlaja cc.helsinki.fi>
Test by: Garrett Rooney
* file_io/win32/seek.c
(apr_file_seek): Fix APR_END case of APR_XTHREAD case.
* test/testfile.c
(test_xthread): New test.
(testfile): Run new test.
* CHANGES: Note change.
Modified:
apr/apr/branches/1.2.x/CHANGES
apr/apr/branches/1.2.x/file_io/win32/seek.c
apr/apr/branches/1.2.x/test/testfile.c
Modified: apr/apr/branches/1.2.x/CHANGES
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.2.x/CHANGES?rev=373454&r1=373453&r2=373454&view=diff
==============================================================================
--- apr/apr/branches/1.2.x/CHANGES (original)
+++ apr/apr/branches/1.2.x/CHANGES Sun Jan 29 22:55:09 2006
@@ -1,5 +1,8 @@
Changes for APR 1.2.3
+ *) Fix seeks with files opened in xthread mode for append on win32.
+ [M Joonas Pihlaja <jpihlaja cc.helsinki.fi>, Garrett Rooney]
+
*) Keep testpipe.c from hanging on win32. [Garrett Rooney]
*) Cause apr_file_write_full on win32 to consider the timeout value set by
Modified: apr/apr/branches/1.2.x/file_io/win32/seek.c
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.2.x/file_io/win32/seek.c?rev=373454&r1=373453&r2=373454&view=diff
==============================================================================
--- apr/apr/branches/1.2.x/file_io/win32/seek.c (original)
+++ apr/apr/branches/1.2.x/file_io/win32/seek.c Sun Jan 29 22:55:09 2006
@@ -105,8 +105,8 @@
case APR_END:
rc = apr_file_info_get(&finfo, APR_FINFO_SIZE, thefile);
- if (rc == APR_SUCCESS && finfo.size - *offset < 0)
- thefile->filePtr = finfo.size - *offset;
+ if (rc == APR_SUCCESS && finfo.size + *offset >= 0)
+ thefile->filePtr = finfo.size + *offset;
break;
default:
Modified: apr/apr/branches/1.2.x/test/testfile.c
URL: http://svn.apache.org/viewcvs/apr/apr/branches/1.2.x/test/testfile.c?rev=373454&r1=373453&r2=373454&view=diff
==============================================================================
--- apr/apr/branches/1.2.x/test/testfile.c (original)
+++ apr/apr/branches/1.2.x/test/testfile.c Sun Jan 29 22:55:09 2006
@@ -779,6 +779,56 @@
apr_file_close(f);
}
+static void test_xthread(abts_case *tc, void *data)
+{
+ apr_file_t *f;
+ const char *fname = "data/testxthread.dat";
+ apr_status_t rv;
+ apr_int32_t flags = APR_CREATE|APR_READ|APR_WRITE|APR_APPEND|APR_XTHREAD;
+ char buf[128] = { 0 };
+
+ /* Test for bug 38438, opening file with append + xthread and seeking to
+ the end of the file resulted in writes going to the beginning not the
+ end. */
+
+ apr_file_remove(fname, p);
+
+ APR_ASSERT_SUCCESS(tc, "open test file",
+ apr_file_open(&f, fname, flags,
+ APR_UREAD|APR_UWRITE, p));
+
+ APR_ASSERT_SUCCESS(tc, "write should succeed",
+ apr_file_puts("hello", f));
+
+ apr_file_close(f);
+
+ APR_ASSERT_SUCCESS(tc, "open test file",
+ apr_file_open(&f, fname, flags,
+ APR_UREAD|APR_UWRITE, p));
+
+ /* Seek to the end. */
+ {
+ apr_off_t offset = 0;
+
+ rv = apr_file_seek(f, APR_END, &offset);
+ }
+
+ APR_ASSERT_SUCCESS(tc, "more writes should succeed",
+ apr_file_puts("world", f));
+
+ /* Back to the beginning. */
+ {
+ apr_off_t offset = 0;
+
+ rv = apr_file_seek(f, APR_SET, &offset);
+ }
+
+ apr_file_read_full(f, buf, sizeof(buf), NULL);
+
+ ABTS_STR_EQUAL(tc, "helloworld", buf);
+
+ apr_file_close(f);
+}
abts_suite *testfile(abts_suite *suite)
{
@@ -812,6 +862,7 @@
abts_run_test(suite, test_bigfprintf, NULL);
abts_run_test(suite, test_fail_write_flush, NULL);
abts_run_test(suite, test_fail_read_flush, NULL);
+ abts_run_test(suite, test_xthread, NULL);
return suite;
}