aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/plugins/socket_dynamic
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2010-10-15 17:24:23 +0200
committerTobias Brunner <tobias@strongswan.org>2010-10-15 17:30:21 +0200
commitfa208494319efd0bc48fa63bfff9dac9bef84a55 (patch)
treecd20dae44e8f03eec2d505400830db0b84a7d656 /src/libcharon/plugins/socket_dynamic
parent4de8398f931e1777c685710c87ad412bcf6715c4 (diff)
downloadstrongswan-fa208494319efd0bc48fa63bfff9dac9bef84a55.tar.bz2
strongswan-fa208494319efd0bc48fa63bfff9dac9bef84a55.tar.xz
Deferred instantiation of socket implmentations until registration.
Instantiating the implementations on plugin load was problematic in case multiple socket plugins were loaded. Now, the first one registered is instantiated.
Diffstat (limited to 'src/libcharon/plugins/socket_dynamic')
-rw-r--r--src/libcharon/plugins/socket_dynamic/socket_dynamic_plugin.c19
-rw-r--r--src/libcharon/plugins/socket_dynamic/socket_dynamic_socket.c6
2 files changed, 9 insertions, 16 deletions
diff --git a/src/libcharon/plugins/socket_dynamic/socket_dynamic_plugin.c b/src/libcharon/plugins/socket_dynamic/socket_dynamic_plugin.c
index eb3cbb9d6..a6ff14efd 100644
--- a/src/libcharon/plugins/socket_dynamic/socket_dynamic_plugin.c
+++ b/src/libcharon/plugins/socket_dynamic/socket_dynamic_plugin.c
@@ -1,4 +1,6 @@
/*
+ * Copyright (C) 2010 Tobias Brunner
+ * Hochschule fuer Technik Rapperswil
* Copyright (C) 2010 Martin Willi
* Copyright (C) 2010 revosec AG
*
@@ -31,17 +33,13 @@ struct private_socket_dynamic_plugin_t {
*/
socket_dynamic_plugin_t public;
- /**
- * Socket instance.
- */
- socket_dynamic_socket_t *socket;
};
METHOD(plugin_t, destroy, void,
private_socket_dynamic_plugin_t *this)
{
- charon->socket->remove_socket(charon->socket, &this->socket->socket);
- this->socket->destroy(this->socket);
+ charon->socket->remove_socket(charon->socket,
+ (socket_constructor_t)socket_dynamic_socket_create);
free(this);
}
@@ -58,15 +56,10 @@ plugin_t *socket_dynamic_plugin_create()
.destroy = _destroy,
},
},
- .socket = socket_dynamic_socket_create(),
);
- if (!this->socket)
- {
- free(this);
- return NULL;
- }
- charon->socket->add_socket(charon->socket, &this->socket->socket);
+ charon->socket->add_socket(charon->socket,
+ (socket_constructor_t)socket_dynamic_socket_create);
return &this->public.plugin;
}
diff --git a/src/libcharon/plugins/socket_dynamic/socket_dynamic_socket.c b/src/libcharon/plugins/socket_dynamic/socket_dynamic_socket.c
index 861ebfd6f..74dba82cc 100644
--- a/src/libcharon/plugins/socket_dynamic/socket_dynamic_socket.c
+++ b/src/libcharon/plugins/socket_dynamic/socket_dynamic_socket.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006-2009 Tobias Brunner
+ * Copyright (C) 2006-2010 Tobias Brunner
* Copyright (C) 2006 Daniel Roethlisberger
* Copyright (C) 2005-2010 Martin Willi
* Copyright (C) 2005 Jan Hutter
@@ -572,7 +572,7 @@ METHOD(socket_t, sender, status_t,
return SUCCESS;
}
-METHOD(socket_dynamic_socket_t, destroy, void,
+METHOD(socket_t, destroy, void,
private_socket_dynamic_socket_t *this)
{
enumerator_t *enumerator;
@@ -605,8 +605,8 @@ socket_dynamic_socket_t *socket_dynamic_socket_create()
.socket = {
.send = _sender,
.receive = _receiver,
+ .destroy = _destroy,
},
- .destroy = _destroy,
},
.lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
.max_packet = lib->settings->get_int(lib->settings,