carnold 2005/04/28 18:23:16
Modified: . apr-build.xml build.xml
include/log4cxx/helpers socketimpl.h
src socketimpl.cpp
Log:
LOGCXX-80: APR Network appenders, Windows iter
Revision Changes Path
1.14 +1 -0 logging-log4cxx/apr-build.xml
Index: apr-build.xml
===================================================================
RCS file: /home/cvs/logging-log4cxx/apr-build.xml,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- apr-build.xml 13 Mar 2005 06:20:45 -0000 1.13
+++ apr-build.xml 29 Apr 2005 01:23:16 -0000 1.14
@@ -180,6 +180,7 @@
<fileset dir="${include.dir}/arch" includes="*.h"/>
<fileset dir="${include.dir}/arch/${arch}" includes="*.h"/>
<fileset dir="${include.dir}/arch/unix" includes="*.h"/>
+ <fileset dir="${src.dir}/support/unix" includes="waitio.c"/>
<includepath path="${include.dir}"/>
<includepath path="${include.dir}/arch"/>
<includepath path="${include.dir}/arch/${arch}"/>
1.62 +1 -1 logging-log4cxx/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/logging-log4cxx/build.xml,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- build.xml 28 Apr 2005 20:53:45 -0000 1.61
+++ build.xml 29 Apr 2005 01:23:16 -0000 1.62
@@ -8,7 +8,7 @@
<libset libs="iconv" if="has-iconv"/>
<libset libs="xml2 pthread" if="is-unix"/>
<libset libs="expat" if="has-expat"/>
- <libset libs="advapi32 odbc32 ws2_32" if="is-windows"/>
+ <libset libs="advapi32 odbc32 ws2_32 mswsock" if="is-windows"/>
<libset libs="stdc++" if="is-gcc"/>
<libset libs="cw32mt" if="is-bcc"/>
'>]>
1.18 +9 -12 logging-log4cxx/include/log4cxx/helpers/socketimpl.h
Index: socketimpl.h
===================================================================
RCS file: /home/cvs/logging-log4cxx/include/log4cxx/helpers/socketimpl.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- socketimpl.h 29 Apr 2005 00:36:13 -0000 1.17
+++ socketimpl.h 29 Apr 2005 01:23:16 -0000 1.18
@@ -23,9 +23,6 @@
#include <log4cxx/helpers/exception.h>
#include <log4cxx/helpers/pool.h>
-#include "apr_network_io.h"
-#include "apr_lib.h"
-
namespace log4cxx
{
@@ -38,20 +35,20 @@
{
public:
SocketException();
- SocketException(apr_status_t status);
+ SocketException(log4cxx_status_t status);
SocketException(const SocketException&);
virtual ~SocketException() throw();
const char* what() const throw();
- apr_status_t getErrorNumber() const;
+ log4cxx_status_t getErrorNumber() const;
protected:
- SocketException(const char* what, apr_status_t
status);
+ SocketException(const char* what, log4cxx_status_t
status);
private:
SocketException& operator=(const SocketException&);
/** The APR error code */
- apr_status_t errorNumber;
+ log4cxx_status_t errorNumber;
/** The container for the message returned by what()
*/
std::string msg;
@@ -89,7 +86,7 @@
virtual ~PlatformSocketException() throw();
protected:
- PlatformSocketException(const char *what,
apr_status_t status);
+ PlatformSocketException(const char *what,
log4cxx_status_t status);
private:
PlatformSocketException& operator=(const
PlatformSocketException&);
@@ -104,7 +101,7 @@
{
public:
ConnectException();
- ConnectException(apr_status_t status);
+ ConnectException(log4cxx_status_t status);
ConnectException(const ConnectException& src);
virtual ~ConnectException() throw();
@@ -120,7 +117,7 @@
{
public:
BindException();
- BindException(apr_status_t status);
+ BindException(log4cxx_status_t status);
BindException(const BindException&);
virtual ~BindException() throw();
@@ -179,7 +176,7 @@
Pool memoryPool;
/** The APR socket */
- apr_socket_t *socket;
+ void *socket;
/** The local port number to which this socket is
connected. */
int localport;
@@ -216,7 +213,7 @@
/** Binds this socket to the specified port number
on the specified host.
@param host the host address
- @param port the port number.
+ @param port the port number.
@exception BindException if an I/O error occurs when
binding this socket.
*/
void bind(InetAddress host, int port);
1.24 +21 -11 logging-log4cxx/src/socketimpl.cpp
Index: socketimpl.cpp
===================================================================
RCS file: /home/cvs/logging-log4cxx/src/socketimpl.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- socketimpl.cpp 29 Apr 2005 00:36:13 -0000 1.23
+++ socketimpl.cpp 29 Apr 2005 01:23:16 -0000 1.24
@@ -21,6 +21,10 @@
#include <log4cxx/helpers/pool.h>
#include <log4cxx/helpers/transcoder.h>
+#include "apr_network_io.h"
+#include "apr_lib.h"
+
+
using namespace log4cxx;
using namespace log4cxx::helpers;
@@ -161,7 +165,7 @@
{
// If a timeout is set then wait at most for the specified timeout
if (getSoTimeout() > 0) {
- apr_status_t status = apr_wait_for_io_or_timeout(NULL, socket, 0);
+ apr_status_t status = apr_wait_for_io_or_timeout(NULL,
(apr_socket_t*) socket, 0);
if (status == APR_TIMEUP) {
throw SocketTimeoutException();
}
@@ -173,7 +177,7 @@
// Accept new connection
apr_socket_t *clientSocket = 0;
apr_status_t status =
- apr_socket_accept(&clientSocket, socket, (apr_pool_t*)
memoryPool.getAPRPool());
+ apr_socket_accept(&clientSocket, (apr_socket_t*) socket,
(apr_pool_t*) memoryPool.getAPRPool());
if (status != APR_SUCCESS) {
throw SocketException(status);
}
@@ -216,7 +220,7 @@
}
// bind the socket to the address
- status = apr_socket_bind(socket, server_addr);
+ status = apr_socket_bind((apr_socket_t*) socket, server_addr);
if (status != APR_SUCCESS) {
throw BindException(status);
}
@@ -229,7 +233,7 @@
{
if (socket != 0) {
LOGLOG_DEBUG(LOG4CXX_STR("closing socket"));
- apr_status_t status = apr_socket_close(socket);
+ apr_status_t status = apr_socket_close((apr_socket_t*) socket);
if (status != APR_SUCCESS) {
throw SocketException(status);
}
@@ -258,7 +262,7 @@
}
// connect the socket
- status = apr_socket_connect(socket, client_addr);
+ status = apr_socket_connect((apr_socket_t*) socket, client_addr);
if (status != APR_SUCCESS) {
throw ConnectException();
}
@@ -276,9 +280,11 @@
/** Creates either a stream or a datagram socket. */
void SocketImpl::create(bool stream)
{
+ apr_socket_t* newSocket;
apr_status_t status =
- apr_socket_create(&socket, APR_INET, stream ? SOCK_STREAM : SOCK_DGRAM,
+ apr_socket_create(&newSocket, APR_INET, stream ? SOCK_STREAM :
SOCK_DGRAM,
APR_PROTO_TCP, (apr_pool_t*) memoryPool.getAPRPool());
+ socket = newSocket;
if (status != APR_SUCCESS) {
throw SocketException(status);
}
@@ -290,7 +296,7 @@
void SocketImpl::listen(int backlog)
{
- apr_status_t status = apr_socket_listen (socket, backlog);
+ apr_status_t status = apr_socket_listen ((apr_socket_t*) socket, backlog);
if (status != APR_SUCCESS) {
throw SocketException(status);
}
@@ -317,7 +323,7 @@
while ((size_t)(p - (char *)buf) < len)
{
apr_size_t len_read = len - (p - (const char *)buf);
- apr_status_t status = apr_socket_recv(socket, p, &len_read);
+ apr_status_t status = apr_socket_recv((apr_socket_t*) socket, p,
&len_read);
if (status != APR_SUCCESS) {
throw SocketException(status);
}
@@ -346,9 +352,13 @@
// signal. Otherwise, when the client has closed the connection,
// the send() function would not return an error but call the
// SIGPIPE handler.
+#if APR_HAVE_SIGACTION
apr_sigfunc_t* old = apr_signal(SIGPIPE, SIG_IGN);
- apr_status_t status = apr_socket_send(socket, p, &len_written);
+ apr_status_t status = apr_socket_send((apr_socket_t*) socket, p,
&len_written);
apr_signal(SIGPIPE, old);
+#else
+ apr_status_t status = apr_socket_send((apr_socket_t*) socket, p,
&len_written);
+#endif
if (status != APR_SUCCESS) {
throw SocketException(status);
@@ -368,7 +378,7 @@
int SocketImpl::getSoTimeout() const
{
apr_interval_time_t timeout;
- apr_status_t status = apr_socket_timeout_get(socket, &timeout);
+ apr_status_t status = apr_socket_timeout_get((apr_socket_t*) socket,
&timeout);
if (status != APR_SUCCESS) {
throw SocketException(status);
}
@@ -381,7 +391,7 @@
void SocketImpl::setSoTimeout(int timeout)
{
apr_interval_time_t time = timeout * 1000;
- apr_status_t status = apr_socket_timeout_set(socket, time);
+ apr_status_t status = apr_socket_timeout_set((apr_socket_t*) socket, time);
if (status != APR_SUCCESS) {
throw SocketException(status);
}