From commits-return-8960-apmail-commons-commits-archive=commons.apache.org@commons.apache.org Thu Oct 01 15:53:50 2009 Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 38190 invoked from network); 1 Oct 2009 15:53:50 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Oct 2009 15:53:50 -0000 Received: (qmail 63401 invoked by uid 500); 1 Oct 2009 15:53:49 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 63334 invoked by uid 500); 1 Oct 2009 15:53:48 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 63306 invoked by uid 99); 1 Oct 2009 15:53:48 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Oct 2009 15:53:48 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Oct 2009 15:53:46 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E2E9523888D4; Thu, 1 Oct 2009 15:52:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r820696 - /commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c Date: Thu, 01 Oct 2009 15:52:54 -0000 To: commits@commons.apache.org From: mturk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091001155254.E2E9523888D4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mturk Date: Thu Oct 1 15:52:54 2009 New Revision: 820696 URL: http://svn.apache.org/viewvc?rev=820696&view=rev Log: Use infinite timeout if not set for full-write routines Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c?rev=820696&r1=820695&r2=820696&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/fsysio.c Thu Oct 1 15:52:54 2009 @@ -277,6 +277,23 @@ return errno; } +static int wait_for_io(acr_file_t *f, int for_read) +{ + int rc, timeout = f->timeout ? (int)(f->timeout / 1000) : -1; + f->ppoll.fd = f->fd; + f->ppoll.events = for_read ? POLLIN : POLLOUT; + + do { + rc = poll(&f->ppoll, 1, timeout); + } while (rc == -1 && errno == EINTR); + if (rc == 0) + return ACR_TIMEUP; + else if (rc > 0) + return ACR_SUCCESS; + else + return errno; +} + ACR_IO_EXPORT_DECLARE(jint, FileSystem, lock0)(ACR_JNISTDARGS, jint file, jint type) @@ -1260,9 +1277,8 @@ wb = bb + po; do { wr = r_write(f->fd, wb, cs); - if (wr == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) && - f->timeout != 0) { - if ((rc = wait_for_io_or_timeout(f, 0)) == 0) { + if (wr == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) { + if ((rc = wait_for_io(f, 0)) == 0) { wr = r_write(f->fd, wb, cs); } else if (rc != ACR_TIMEUP) @@ -1332,9 +1348,8 @@ pb = pb + po; do { wr = r_write(f->fd, pb, cs); - if (wr == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) && - f->timeout != 0) { - if ((rc = wait_for_io_or_timeout(f, 0)) == 0) { + if (wr == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) { + if ((rc = wait_for_io(f, 0)) == 0) { wr = r_write(f->fd, pb, cs); } else if (rc != ACR_TIMEUP) @@ -1408,9 +1423,8 @@ pb = pb + po; do { wr = r_write(f->fd, pb, cs); - if (wr == -1 && (errno == EAGAIN || errno == EWOULDBLOCK) && - f->timeout != 0) { - if ((rc = wait_for_io_or_timeout(f, 0)) == 0) { + if (wr == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) { + if ((rc = wait_for_io(f, 0)) == 0) { wr = r_write(f->fd, pb, cs); } else if (rc != ACR_TIMEUP)