Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7145660ED for ; Fri, 3 Jun 2011 05:35:05 +0000 (UTC) Received: (qmail 4554 invoked by uid 500); 3 Jun 2011 05:35:01 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 4461 invoked by uid 500); 3 Jun 2011 05:34:59 -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 4445 invoked by uid 99); 3 Jun 2011 05:34:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Jun 2011 05:34:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.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; Fri, 03 Jun 2011 05:34:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id ED20F2388A29; Fri, 3 Jun 2011 05:34:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1130897 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/io/ java/org/apache/commons/runtime/net/ native/include/acr/ native/os/unix/ native/shared/ Date: Fri, 03 Jun 2011 05:34:33 -0000 To: commits@commons.apache.org From: mturk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110603053433.ED20F2388A29@eris.apache.org> Author: mturk Date: Fri Jun 3 05:34:33 2011 New Revision: 1130897 URL: http://svn.apache.org/viewvc?rev=1130897&view=rev Log: Add two more nonblocking op exceptions Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/OperationInProgressException.java (with props) commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/OperationWouldBlockException.java (with props) Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Poll.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionKey.java commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionOps.java commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h commons/sandbox/runtime/trunk/src/main/native/include/acr/iodefs.h commons/sandbox/runtime/trunk/src/main/native/os/unix/poll.c commons/sandbox/runtime/trunk/src/main/native/os/unix/selector.c commons/sandbox/runtime/trunk/src/main/native/os/unix/usock.c commons/sandbox/runtime/trunk/src/main/native/shared/error.c Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/OperationInProgressException.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/OperationInProgressException.java?rev=1130897&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/OperationInProgressException.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/OperationInProgressException.java Fri Jun 3 05:34:33 2011 @@ -0,0 +1,40 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.runtime.io; +import java.io.IOException; + +/** + * OperationInProgressException is thrown when an attempt is made to + * invoke an operation on a nonblocking {@code Descriptor} and + * the operation cannot be completed immediately. + * This class mimics the os {@code EINPROGRESS} error. + * + * @since Runtime 1.0 + */ +public class OperationInProgressException extends IOException +{ + + public OperationInProgressException() + { + super(); + } + + public OperationInProgressException(String msg) + { + super(msg); + } +} Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/OperationInProgressException.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/OperationWouldBlockException.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/OperationWouldBlockException.java?rev=1130897&view=auto ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/OperationWouldBlockException.java (added) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/OperationWouldBlockException.java Fri Jun 3 05:34:33 2011 @@ -0,0 +1,40 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.runtime.io; +import java.io.IOException; + +/** + * OperationWouldBlockException is thrown when an attempt is made to + * invoke an operation on a nonblocking {@code Descriptor} and + * the operation would block. + * This class mimics the os {@code EWOULDBLOCK} or {@code EAGAIN} error. + * + * @since Runtime 1.0 + */ +public class OperationWouldBlockException extends IOException +{ + + public OperationWouldBlockException() + { + super(); + } + + public OperationWouldBlockException(String msg) + { + super(msg); + } +} Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/io/OperationWouldBlockException.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Poll.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Poll.java?rev=1130897&r1=1130896&r2=1130897&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Poll.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/Poll.java Fri Jun 3 05:34:33 2011 @@ -37,15 +37,15 @@ public final class Poll */ public static final short POLLIN = 0x0001; /** + * Writing now will not block. + */ + public static final short POLLOUT = 0x0004; + /** * There is urgent data to read. * e.g., out-of-band data on TCP socket; pseudo-terminal master in packet mode * has seen state change in slave. */ - public static final short POLLPRI = 0x0008; - /** - * Writing now will not block. - */ - public static final short POLLOUT = 0x0010; + public static final short POLLPRI = 0x0010; /** * A Stream socket peer closed connection, or shut down writing half of connection. */ Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionKey.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionKey.java?rev=1130897&r1=1130896&r2=1130897&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionKey.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionKey.java Fri Jun 3 05:34:33 2011 @@ -32,26 +32,26 @@ public abstract class SelectionKey private Object attachment; private int timeout; - /** Accept operation. + /** Read operation. *

*

*/ - public static final int OP_ACCEPT = 0x0001; - /** Connect operation. + public static final int OP_READ = 0x0001; + /** Accept operation. *

*

*/ - public static final int OP_CONNECT = 0x0002; - /** Read operation. + public static final int OP_ACCEPT = 0x0002; + /** Write operation. *

*

*/ - public static final int OP_READ = 0x0004; - /** Write operation. + public static final int OP_WRITE = 0x0004; + /** Connect operation. *

*

*/ - public static final int OP_WRITE = 0x0008; + public static final int OP_CONNECT = 0x0008; /** * Constructs a new {@code SelectionKey} for given selector and enpoint Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionOps.java URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionOps.java?rev=1130897&r1=1130896&r2=1130897&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionOps.java (original) +++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SelectionOps.java Fri Jun 3 05:34:33 2011 @@ -27,26 +27,26 @@ final class SelectionOps // No Instance } - /** Accept operation. + /** Read operation. *

*

*/ - public static final int ACCEPT = 0x0001; - /** Connect operation. + public static final int READ = 0x0001; + /** Accept operation. *

*

*/ - public static final int CONNECT = 0x0002; - /** Read operation. + public static final int ACCEPT = 0x0002; + /** Write operation. *

*

*/ - public static final int READ = 0x0004; - /** Write operation. + public static final int WRITE = 0x0004; + /** Connect operation. *

*

*/ - public static final int WRITE = 0x0008; + public static final int CONNECT = 0x0008; /** There is urgent data to read. *

*

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h?rev=1130897&r1=1130896&r2=1130897&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h (original) +++ commons/sandbox/runtime/trunk/src/main/native/include/acr/error.h Fri Jun 3 05:34:33 2011 @@ -54,6 +54,8 @@ enum { ACR_EX_ENOENT, /* NoSuchObjectException */ ACR_EX_ENOTIMPL, /* OperationNotImplementedException */ ACR_EX_EPERM, /* OperationNotPermittedException */ + ACR_EX_EINPROGRESS, /* OperationInProgressException */ + ACR_EX_EWOULDBLOCK, /* OperationWouldBlockException */ ACR_EX_TIMEOUT, /* TimeoutException */ ACR_EX_ESYS, /* SystemException */ ACR_EX_ENET, /* NetworkException */ Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr/iodefs.h URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/iodefs.h?rev=1130897&r1=1130896&r2=1130897&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/include/acr/iodefs.h (original) +++ commons/sandbox/runtime/trunk/src/main/native/include/acr/iodefs.h Fri Jun 3 05:34:33 2011 @@ -35,11 +35,12 @@ #define ACR_FOPEN_NOINHERIT 0x010000 /**< Do not inherit files on exec */ #define ACR_FOPEN_INFO 0x020000 /**< Open without READ or WRITE access */ -#define ACR_OP_ACCEPT 0x0001 -#define ACR_OP_CONNECT 0x0002 -#define ACR_OP_READ 0x0004 -#define ACR_OP_INP 0x0007 /**< ACCEPT|CONNECT|READ */ -#define ACR_OP_WRITE 0x0008 +#define ACR_OP_READ 0x0001 +#define ACR_OP_ACCEPT 0x0002 +#define ACR_OP_WRITE 0x0004 +#define ACR_OP_CONNECT 0x0008 +#define ACR_OP_INP 0x0003 /**< ACCEPT|READ */ +#define ACR_OP_OUT 0x000C /**< CONNECT|WRITE */ #define ACR_OP_PRI 0x0010 #define ACR_OP_RDHUP 0x0020 #define ACR_OP_HANGUP 0x0040 Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/poll.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/poll.c?rev=1130897&r1=1130896&r2=1130897&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/unix/poll.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/poll.c Fri Jun 3 05:34:33 2011 @@ -33,10 +33,10 @@ static short ieventt(int event) if (event & ACR_OP_INP) rv |= POLLIN; + if (event & ACR_OP_OUT) + rv |= POLLOUT; if (event & ACR_OP_PRI) rv |= POLLPRI; - if (event & ACR_OP_WRITE) - rv |= POLLOUT; /* POLLERR, POLLHUP, and POLLNVAL aren't valid as requested events */ return rv; @@ -48,10 +48,10 @@ static short reventt(short event) if (event & POLLIN) rv |= ACR_OP_INP; + if (event & POLLOUT) + rv |= ACR_OP_OUT; if (event & POLLPRI) rv |= ACR_OP_PRI; - if (event & POLLOUT) - rv |= ACR_OP_WRITE; if (event & POLLERR) rv |= ACR_OP_ERROR; if (event & POLLHUP) Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/selector.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/selector.c?rev=1130897&r1=1130896&r2=1130897&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/unix/selector.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/selector.c Fri Jun 3 05:34:33 2011 @@ -56,7 +56,7 @@ static short ieventt(int event) if (event & ACR_OP_INP) rv |= POLLIN; - if (event & ACR_OP_WRITE) + if (event & ACR_OP_OUT) rv |= POLLOUT; if (event & ACR_OP_PRI) rv |= POLLPRI; @@ -72,7 +72,7 @@ static short reventt(short event) if (event & POLLIN) rv |= ACR_OP_INP; if (event & POLLOUT) - rv |= ACR_OP_WRITE; + rv |= ACR_OP_OUT; if (event & POLLPRI) rv |= ACR_OP_PRI; if (event & POLLERR) Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/usock.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/usock.c?rev=1130897&r1=1130896&r2=1130897&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/unix/usock.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/unix/usock.c Fri Jun 3 05:34:33 2011 @@ -54,6 +54,25 @@ ACR_NET_EXPORT(jint, LocalEndpoint, nonb return AcrNonblock(fd, on); } +ACR_NET_EXPORT(jint, LocalEndpoint, connect0)(JNI_STDARGS, jint fd, + jbyteArray aa) +{ + int sd; + acr_sockaddr_t *sa = SOCKADDR_CAST(aa); + + do { + /* Restartable connect */ + sd = connect(fd, (const struct sockaddr *)&sa->sa, sa->salen); + } while (sd == -1 && errno == EINTR); + + if (sd == -1) { + ACR_THROW_NET_ERRNO(); + return -1; + } + SOCKADDR_RELEASE(aa, sa); + return sd; +} + ACR_NET_EXPORT(jint, LocalServerEndpoint, bind0)(JNI_STDARGS, jint fd, jbyteArray aa, jint backlog) Modified: commons/sandbox/runtime/trunk/src/main/native/shared/error.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/error.c?rev=1130897&r1=1130896&r2=1130897&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/shared/error.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/shared/error.c Fri Jun 3 05:34:33 2011 @@ -36,8 +36,8 @@ static struct { { 0, "java/lang/OutOfMemoryError" }, /* ENOMEM */ { 0, "java/lang/NullPointerException" }, /* EISNULL */ { 0, "java/lang/UnsupportedOperationException" }, /* ENOSYS */ - { 0, "java/io/IOException" }, /* I/O Error */ - { 0, "java/net/SocketException" }, /* Net Error */ + { 0, "java/io/IOException" }, /* EX_EIO */ + { 0, "java/net/SocketException" }, /* EX_ESOCK */ { 0, ACR_IO_CP "InvalidDescriptorException" }, /* EBADF */ { 0, ACR_CLASS_PATH "AccessDeniedException" }, /* EACCESS */ @@ -48,9 +48,11 @@ static struct { { 0, ACR_CLASS_PATH "NoSuchObjectException" }, /* ENOENT */ { 0, ACR_CLASS_PATH "OperationNotImplementedException" }, /* ENOTIMPL */ { 0, ACR_CLASS_PATH "OperationNotPermittedException" }, /* EPERM */ + { 0, ACR_IO_CP "OperationInProgressException" }, /* EINPROGRESS */ + { 0, ACR_IO_CP "OperationWouldBlockException" }, /* EWOULDBLOCK */ { 0, ACR_CLASS_PATH "TimeoutException" }, /* ETIMEOUT */ - { 0, ACR_CLASS_PATH "SystemException" }, - { 0, ACR_NET_CP "NetworkException" }, + { 0, ACR_CLASS_PATH "SystemException" }, /* EX_ESYS */ + { 0, ACR_NET_CP "NetworkException" }, /* EX_ENET */ { 0, ACR_CLASS_PATH "OverflowException" } /* EOVERFLOW */ }; @@ -760,6 +762,10 @@ AcrThrowByError(JNI_STDENV, int def, int cls = ACR_EX_ENOMEM; else if (ACR_STATUS_IS_EINVAL(err)) cls = ACR_EX_EINVAL; + else if (ACR_STATUS_IS_EINPROGRESS(err)) + cls = ACR_EX_EINPROGRESS; + else if (ACR_STATUS_IS_EAGAIN(err)) + cls = ACR_EX_EWOULDBLOCK; else if (ACR_STATUS_IS_TIMEUP(err)) cls = ACR_EX_TIMEOUT; else if (err == ACR_EPERM)