Return-Path: Delivered-To: apmail-apr-commits-archive@www.apache.org Received: (qmail 34289 invoked from network); 30 Jan 2006 07:05:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 30 Jan 2006 07:05:00 -0000 Received: (qmail 13854 invoked by uid 500); 30 Jan 2006 07:04:59 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 13742 invoked by uid 500); 30 Jan 2006 07:04:59 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 13731 invoked by uid 99); 30 Jan 2006 07:04:59 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 29 Jan 2006 23:04:59 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 29 Jan 2006 23:04:58 -0800 Received: (qmail 34229 invoked by uid 65534); 30 Jan 2006 07:04:38 -0000 Message-ID: <20060130070438.34228.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r373455 - in /apr/apr/branches/0.9.x: CHANGES file_io/win32/seek.c test/testfile.c Date: Mon, 30 Jan 2006 07:04:37 -0000 To: commits@apr.apache.org From: rooneg@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: rooneg Date: Sun Jan 29 23:04:30 2006 New Revision: 373455 URL: http://svn.apache.org/viewcvs?rev=373455&view=rev Log: Merge r373453 into 0.9.x, with necessary changes to tests to account for the old test framework. Original log message: Fix bug #38438, seeks are broken for files opened for append in xthread mode on win32. Submitted by: M Joonas Pihlaja 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/0.9.x/CHANGES apr/apr/branches/0.9.x/file_io/win32/seek.c apr/apr/branches/0.9.x/test/testfile.c Modified: apr/apr/branches/0.9.x/CHANGES URL: http://svn.apache.org/viewcvs/apr/apr/branches/0.9.x/CHANGES?rev=373455&r1=373454&r2=373455&view=diff ============================================================================== --- apr/apr/branches/0.9.x/CHANGES (original) +++ apr/apr/branches/0.9.x/CHANGES Sun Jan 29 23:04:30 2006 @@ -1,5 +1,8 @@ Changes with APR 0.9.8 + *) Fix seeks with files opened in xthread mode for append on win32. + [M Joonas Pihlaja , 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/0.9.x/file_io/win32/seek.c URL: http://svn.apache.org/viewcvs/apr/apr/branches/0.9.x/file_io/win32/seek.c?rev=373455&r1=373454&r2=373455&view=diff ============================================================================== --- apr/apr/branches/0.9.x/file_io/win32/seek.c (original) +++ apr/apr/branches/0.9.x/file_io/win32/seek.c Sun Jan 29 23:04:30 2006 @@ -99,8 +99,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/0.9.x/test/testfile.c URL: http://svn.apache.org/viewcvs/apr/apr/branches/0.9.x/test/testfile.c?rev=373455&r1=373454&r2=373455&view=diff ============================================================================== --- apr/apr/branches/0.9.x/test/testfile.c (original) +++ apr/apr/branches/0.9.x/test/testfile.c Sun Jan 29 23:04:30 2006 @@ -596,6 +596,55 @@ apr_file_remove(fname, p); } +static void test_xthread(CuTest *tc) +{ + 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); + + rv = apr_file_open(&f, fname, flags, APR_UREAD|APR_UWRITE, p); + CuAssert(tc, "open test file", rv == APR_SUCCESS); + + rv = apr_file_puts("hello", f); + CuAssert(tc, "write should succeed", rv == APR_SUCCESS); + + apr_file_close(f); + + rv = apr_file_open(&f, fname, flags, APR_UREAD|APR_UWRITE, p); + CuAssert(tc, "open test file", rv == APR_SUCCESS); + + /* Seek to the end. */ + { + apr_off_t offset = 0; + + rv = apr_file_seek(f, APR_END, &offset); + } + + rv = apr_file_puts("world", f); + CuAssert(tc, "more writes should succeed", rv == APR_SUCCESS); + + /* 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); + + CuAssertStrEquals(tc, "helloworld", buf); + + apr_file_close(f); +} + CuSuite *testfile(void) { CuSuite *suite = CuSuiteNew("File I/O"); @@ -623,6 +672,7 @@ SUITE_ADD_TEST(suite, test_truncate); SUITE_ADD_TEST(suite, test_fail_write_flush); SUITE_ADD_TEST(suite, test_fail_read_flush); + SUITE_ADD_TEST(suite, test_xthread); return suite; }