summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES3
-rw-r--r--file_io/win32/open.c1
-rw-r--r--test/testfile.c51
3 files changed, 1 insertions, 54 deletions
diff --git a/CHANGES b/CHANGES
index d452e6c9f..41b68d0cd 100644
--- a/CHANGES
+++ b/CHANGES
@@ -123,9 +123,6 @@ Changes for APR 2.0.0
*) apr_sockaddr_ip_getbuf, apr_sockaddr_ip_get: Append "%zone" for
IPv6 link-local addresses. [Joe Orton]
- *) Don't seek to the end when opening files with APR_FOPEN_APPEND on Windows.
- [Evgeny Kotkov <evgeny.kotkov visualsvn.com>]
-
*) Fix a deadlock when writing to locked files opened with APR_FOPEN_APPEND
on Windows. PR 50058.
[Evgeny Kotkov <evgeny.kotkov visualsvn.com>]
diff --git a/file_io/win32/open.c b/file_io/win32/open.c
index 8249c6cea..50d27508d 100644
--- a/file_io/win32/open.c
+++ b/file_io/win32/open.c
@@ -369,6 +369,7 @@ APR_DECLARE(apr_status_t) apr_file_open(apr_file_t **new, const char *fname,
if (flag & APR_FOPEN_APPEND) {
(*new)->append = 1;
+ SetFilePointer((*new)->filehand, 0, NULL, FILE_END);
}
if (flag & APR_FOPEN_BUFFERED) {
(*new)->buffered = 1;
diff --git a/test/testfile.c b/test/testfile.c
index 34654521a..7e1102415 100644
--- a/test/testfile.c
+++ b/test/testfile.c
@@ -1799,56 +1799,6 @@ static void test_append_locked(abts_case *tc, void *data)
apr_file_remove(fname, p);
}
-static void test_append_read(abts_case *tc, void *data)
-{
- apr_status_t rv;
- apr_file_t *f;
- const char *fname = "data/testappend_read.dat";
- apr_off_t offset;
- char buf[64];
-
- apr_file_remove(fname, p);
-
- /* Create file with contents. */
- rv = apr_file_open(&f, fname, APR_FOPEN_WRITE | APR_FOPEN_CREATE,
- APR_FPROT_OS_DEFAULT, p);
- APR_ASSERT_SUCCESS(tc, "create file", rv);
-
- rv = apr_file_puts("abc", f);
- APR_ASSERT_SUCCESS(tc, "write to file", rv);
- apr_file_close(f);
-
- /* Re-open it with APR_FOPEN_APPEND. */
- rv = apr_file_open(&f, fname,
- APR_FOPEN_READ | APR_FOPEN_WRITE | APR_FOPEN_APPEND,
- APR_FPROT_OS_DEFAULT, p);
- APR_ASSERT_SUCCESS(tc, "open file", rv);
-
- /* Test the initial file offset. Even though we used APR_FOPEN_APPEND,
- * the offset should be kept in the beginning of the file until the
- * first append. (Previously, the Windows implementation performed
- * an erroneous seek to the file's end right after opening it.)
- */
- offset = 0;
- rv = apr_file_seek(f, APR_CUR, &offset);
- APR_ASSERT_SUCCESS(tc, "get file offset", rv);
- ABTS_INT_EQUAL(tc, 0, (int)offset);
-
- /* Test reading from the file. */
- rv = apr_file_gets(buf, sizeof(buf), f);
- APR_ASSERT_SUCCESS(tc, "read from file", rv);
- ABTS_STR_EQUAL(tc, "abc", buf);
-
- /* Test the file offset after reading. */
- offset = 0;
- rv = apr_file_seek(f, APR_CUR, &offset);
- APR_ASSERT_SUCCESS(tc, "get file offset", rv);
- ABTS_INT_EQUAL(tc, 3, (int)offset);
-
- apr_file_close(f);
- apr_file_remove(fname, p);
-}
-
static void test_empty_read_buffered(abts_case *tc, void *data)
{
apr_status_t rv;
@@ -2303,7 +2253,6 @@ abts_suite *testfile(abts_suite *suite)
abts_run_test(suite, test_write_buffered_spanning_over_bufsize, NULL);
abts_run_test(suite, test_atomic_append, NULL);
abts_run_test(suite, test_append_locked, NULL);
- abts_run_test(suite, test_append_read, NULL);
abts_run_test(suite, test_empty_read_buffered, NULL);
abts_run_test(suite, test_large_read_buffered, NULL);
abts_run_test(suite, test_two_large_reads_buffered, NULL);