summaryrefslogtreecommitdiff
path: root/network_io
diff options
context:
space:
mode:
Diffstat (limited to 'network_io')
-rw-r--r--network_io/os2/sockets.c32
-rw-r--r--network_io/unix/sockets.c30
-rw-r--r--network_io/win32/sockets.c32
3 files changed, 83 insertions, 11 deletions
diff --git a/network_io/os2/sockets.c b/network_io/os2/sockets.c
index cd3b084f5..68061cd8d 100644
--- a/network_io/os2/sockets.c
+++ b/network_io/os2/sockets.c
@@ -58,6 +58,7 @@
#include "apr_general.h"
#include "apr_portable.h"
#include "apr_lib.h"
+#include "apr_strings.h"
#include <errno.h>
#include <string.h>
#include <sys/socket.h>
@@ -241,17 +242,40 @@ APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock,
APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key,
- apr_socket_t *socket)
+ apr_socket_t *sock)
{
- return apr_pool_userdata_get(data, key, socket->cntxt);
+ sock_userdata_t *cur = sock->userdata;
+
+ *data = NULL;
+
+ while (cur) {
+ if (!strcmp(cur->key, key)) {
+ *data = cur->data;
+ break;
+ }
+ cur = cur->next;
+ }
+
+ return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *socket, void *data, const char *key,
+APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, void *data, const char *key,
apr_status_t (*cleanup) (void *))
{
- return apr_pool_userdata_set(data, key, cleanup, socket->cntxt);
+ sock_userdata_t *new = apr_palloc(sock->cntxt, sizeof(sock_userdata_t));
+
+ new->key = apr_pstrdup(sock->cntxt, key);
+ new->data = data;
+ new->next = sock->userdata;
+ sock->userdata = new;
+
+ if (cleanup) {
+ apr_pool_cleanup_register(sock->cntxt, data, cleanup, cleanup);
+ }
+
+ return APR_SUCCESS;
}
APR_DECLARE(apr_status_t) apr_os_sock_get(apr_os_sock_t *thesock, apr_socket_t *sock)
diff --git a/network_io/unix/sockets.c b/network_io/unix/sockets.c
index e1d5c7e80..758be8a38 100644
--- a/network_io/unix/sockets.c
+++ b/network_io/unix/sockets.c
@@ -54,6 +54,7 @@
#include "apr_arch_networkio.h"
#include "apr_network_io.h"
+#include "apr_strings.h"
#include "apr_support.h"
#include "apr_portable.h"
#include "apr_arch_inherit.h"
@@ -318,13 +319,36 @@ apr_status_t apr_socket_connect(apr_socket_t *sock, apr_sockaddr_t *sa)
apr_status_t apr_socket_data_get(void **data, const char *key, apr_socket_t *sock)
{
- return apr_pool_userdata_get(data, key, sock->cntxt);
+ sock_userdata_t *cur = sock->userdata;
+
+ *data = NULL;
+
+ while (cur) {
+ if (!strcmp(cur->key, key)) {
+ *data = cur->data;
+ break;
+ }
+ cur = cur->next;
+ }
+
+ return APR_SUCCESS;
}
apr_status_t apr_socket_data_set(apr_socket_t *sock, void *data, const char *key,
- apr_status_t (*cleanup) (void *))
+ apr_status_t (*cleanup) (void *))
{
- return apr_pool_userdata_set(data, key, cleanup, sock->cntxt);
+ sock_userdata_t *new = apr_palloc(sock->cntxt, sizeof(sock_userdata_t));
+
+ new->key = apr_pstrdup(sock->cntxt, key);
+ new->data = data;
+ new->next = sock->userdata;
+ sock->userdata = new;
+
+ if (cleanup) {
+ apr_pool_cleanup_register(sock->cntxt, data, cleanup, cleanup);
+ }
+
+ return APR_SUCCESS;
}
apr_status_t apr_os_sock_get(apr_os_sock_t *thesock, apr_socket_t *sock)
diff --git a/network_io/win32/sockets.c b/network_io/win32/sockets.c
index 10f648118..590e5758a 100644
--- a/network_io/win32/sockets.c
+++ b/network_io/win32/sockets.c
@@ -57,6 +57,7 @@
#include "apr_general.h"
#include "apr_lib.h"
#include "apr_portable.h"
+#include "apr_strings.h"
#include <string.h>
#include "apr_arch_inherit.h"
#include "apr_arch_misc.h"
@@ -403,16 +404,39 @@ APR_DECLARE(apr_status_t) apr_socket_connect(apr_socket_t *sock,
}
APR_DECLARE(apr_status_t) apr_socket_data_get(void **data, const char *key,
- apr_socket_t *socket)
+ apr_socket_t *sock)
{
- return apr_pool_userdata_get(data, key, socket->cntxt);
+ sock_userdata_t *cur = sock->userdata;
+
+ *data = NULL;
+
+ while (cur) {
+ if (!strcmp(cur->key, key)) {
+ *data = cur->data;
+ break;
+ }
+ cur = cur->next;
+ }
+
+ return APR_SUCCESS;
}
-APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *socket, void *data,
+APR_DECLARE(apr_status_t) apr_socket_data_set(apr_socket_t *sock, void *data,
const char *key,
apr_status_t (*cleanup)(void *))
{
- return apr_pool_userdata_set(data, key, cleanup, socket->cntxt);
+ sock_userdata_t *new = apr_palloc(sock->cntxt, sizeof(sock_userdata_t));
+
+ new->key = apr_pstrdup(sock->cntxt, key);
+ new->data = data;
+ new->next = sock->userdata;
+ sock->userdata = new;
+
+ if (cleanup) {
+ apr_pool_cleanup_register(sock->cntxt, data, cleanup, cleanup);
+ }
+
+ return APR_SUCCESS;
}
APR_DECLARE(apr_status_t) apr_os_sock_get(apr_os_sock_t *thesock,