summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2003-10-14 23:47:29 +0000
committerwrowe <wrowe@13f79535-47bb-0310-9956-ffa450edef68>2003-10-14 23:47:29 +0000
commite93de8614b9d6bc5ce1f75fea9676d1e3c70d127 (patch)
treeb8f4d4eaf3af94c8723aca707920d80f0091e843
parent1619491fe11c05a788c5ce5c940f5aed8f60b537 (diff)
downloadlibapr-e93de8614b9d6bc5ce1f75fea9676d1e3c70d127.tar.gz
Implement apr_socket_atmark, similar to socket_atmark except 1) it's
portable, and 2) the return value is passed by a boolean (int) ref, with errors returned as an apr_status_t. The question is, how portable? sys/sockio.h seems sufficent for me on hp/ux, solaris, linux, osx, and this works on Win32. The Netware and OS2 implementations are best guesses. Submitted by: Jim Jagielski and William Rowe git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@64684 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--configure.in2
-rw-r--r--include/apr.h.in1
-rw-r--r--include/apr.hnw1
-rw-r--r--include/apr.hw1
-rw-r--r--include/apr_network_io.h9
-rw-r--r--include/arch/unix/apr_arch_networkio.h3
-rw-r--r--network_io/os2/sockopt.c13
-rw-r--r--network_io/unix/sockopt.c14
-rw-r--r--network_io/win32/sockopt.c13
9 files changed, 57 insertions, 0 deletions
diff --git a/configure.in b/configure.in
index 0e21f9ea2..4321b1906 100644
--- a/configure.in
+++ b/configure.in
@@ -939,6 +939,7 @@ APR_FLAG_HEADERS(
sys/sendfile.h \
sys/signal.h \
sys/socket.h \
+ sys/sockio.h \
sys/stat.h \
sys/sysctl.h \
sys/syslimits.h \
@@ -988,6 +989,7 @@ AC_SUBST(stringsh)
AC_SUBST(sys_sendfileh)
AC_SUBST(sys_signalh)
AC_SUBST(sys_socketh)
+AC_SUBST(sys_sockioh)
AC_SUBST(sys_typesh)
AC_SUBST(sys_timeh)
AC_SUBST(sys_uioh)
diff --git a/include/apr.h.in b/include/apr.h.in
index fe15ca1fd..4bd5c4b9a 100644
--- a/include/apr.h.in
+++ b/include/apr.h.in
@@ -130,6 +130,7 @@
#define APR_HAVE_SYS_SENDFILE_H @sys_sendfileh@
#define APR_HAVE_SYS_SIGNAL_H @sys_signalh@
#define APR_HAVE_SYS_SOCKET_H @sys_socketh@
+#define APR_HAVE_SYS_SOCKIO_H @sys_sockioh@
#define APR_HAVE_SYS_SYSLIMITS_H @sys_syslimitsh@
#define APR_HAVE_SYS_TIME_H @sys_timeh@
#define APR_HAVE_SYS_TYPES_H @sys_typesh@
diff --git a/include/apr.hnw b/include/apr.hnw
index 8a150b76e..e93175dbd 100644
--- a/include/apr.hnw
+++ b/include/apr.hnw
@@ -143,6 +143,7 @@ extern "C" {
#define APR_HAVE_SYS_SENDFILE_H 0
#define APR_HAVE_SYS_SIGNAL_H 0
#define APR_HAVE_SYS_SOCKET_H 0
+#define APR_HAVE_SYS_SOCKIO_H 0
#define APR_HAVE_SYS_SYSLIMITS_H 0
#define APR_HAVE_SYS_TIME_H 0
#define APR_HAVE_SYS_TYPES_H 1
diff --git a/include/apr.hw b/include/apr.hw
index cc02a6087..1ba302b31 100644
--- a/include/apr.hw
+++ b/include/apr.hw
@@ -171,6 +171,7 @@
#define APR_HAVE_SYS_SENDFILE_H 0
#define APR_HAVE_SYS_SIGNAL_H 0
#define APR_HAVE_SYS_SOCKET_H 0
+#define APR_HAVE_SYS_SOCKIO_H 0
#define APR_HAVE_SYS_SYSLIMITS_H 0
#define APR_HAVE_SYS_TIME_H 0
#define APR_HAVE_SYS_TYPES_H 1
diff --git a/include/apr_network_io.h b/include/apr_network_io.h
index b38fc9dc2..52061d4f3 100644
--- a/include/apr_network_io.h
+++ b/include/apr_network_io.h
@@ -662,6 +662,15 @@ APR_DECLARE(apr_status_t) apr_socket_timeout_get(apr_socket_t *sock,
apr_interval_time_t *t);
/**
+ * Query the specified socket if at the OOB/Urgent data mark
+ * @param sock The socket to query
+ * @param atmark Is set to true if socket is at the OOB/urgent mark,
+ * otherwise is set to false.
+ */
+APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock,
+ int *atmark);
+
+/**
* Return an apr_sockaddr_t from an apr_socket_t
* @param sa The returned apr_sockaddr_t.
* @param which Which interface do we want the apr_sockaddr_t for?
diff --git a/include/arch/unix/apr_arch_networkio.h b/include/arch/unix/apr_arch_networkio.h
index 8250324a0..bcce4fc53 100644
--- a/include/arch/unix/apr_arch_networkio.h
+++ b/include/arch/unix/apr_arch_networkio.h
@@ -102,6 +102,9 @@
#if APR_HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
+#if APR_HAVE_SYS_SOCKIO_H
+#include <sys/sockio.h>
+#endif
#if APR_HAVE_NETDB_H
#include <netdb.h>
#endif
diff --git a/network_io/os2/sockopt.c b/network_io/os2/sockopt.c
index 70bb4c078..0b11f202d 100644
--- a/network_io/os2/sockopt.c
+++ b/network_io/os2/sockopt.c
@@ -156,6 +156,19 @@ APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock,
}
+APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock, int *atmark)
+{
+ int oobmark;
+
+ if (ioctl(sock->socketdes, SIOCATMARK, (void*) &oobmark) < 0)
+ return APR_OS2_STATUS(sock_errno());;
+
+ *atmark = (oobmark != 0);
+
+ return APR_SUCCESS;
+}
+
+
APR_DECLARE(apr_status_t) apr_gethostname(char *buf, apr_int32_t len,
apr_pool_t *cont)
{
diff --git a/network_io/unix/sockopt.c b/network_io/unix/sockopt.c
index cc181b6aa..b4ac81e60 100644
--- a/network_io/unix/sockopt.c
+++ b/network_io/unix/sockopt.c
@@ -55,6 +55,7 @@
#include "apr_arch_networkio.h"
#include "apr_strings.h"
+
static apr_status_t soblock(int sd)
{
/* BeOS uses setsockopt at present for non blocking... */
@@ -369,6 +370,19 @@ apr_status_t apr_socket_opt_get(apr_socket_t *sock,
}
+apr_status_t apr_socket_atmark(apr_socket_t *sock, int *atmark)
+{
+ int oobmark;
+
+ if (ioctl(sock->socketdes, SIOCATMARK, (void*) &oobmark) < 0)
+ return apr_get_netos_error();
+
+ *atmark = (oobmark != 0);
+
+ return APR_SUCCESS;
+}
+
+
apr_status_t apr_gethostname(char *buf, apr_int32_t len, apr_pool_t *cont)
{
if (gethostname(buf, len) == -1) {
diff --git a/network_io/win32/sockopt.c b/network_io/win32/sockopt.c
index e86c6b8b2..4849bd879 100644
--- a/network_io/win32/sockopt.c
+++ b/network_io/win32/sockopt.c
@@ -262,6 +262,19 @@ APR_DECLARE(apr_status_t) apr_socket_opt_get(apr_socket_t *sock,
}
+APR_DECLARE(apr_status_t) apr_socket_atmark(apr_socket_t *sock, int *atmark)
+{
+ u_long oobmark;
+
+ if (ioctlsocket(sock->socketdes, SIOCATMARK, (void*) &oobmark) < 0)
+ return apr_get_netos_error();
+
+ *atmark = (oobmark != 0);
+
+ return APR_SUCCESS;
+}
+
+
APR_DECLARE(apr_status_t) apr_gethostname(char *buf, int len,
apr_pool_t *cont)
{