aboutsummaryrefslogtreecommitdiff
path: root/src/util/plugin.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-06-25 15:37:07 +0000
committerChristian Grothoff <christian@grothoff.org>2010-06-25 15:37:07 +0000
commit94f01bdd2fda575769f01f8072689fa6936af8f4 (patch)
treec2ffd2a36b7babe0b47335f407b3f20e71bb25ba /src/util/plugin.c
parent2d4ae427e8d2a4bc305c42100d5cb35a75916879 (diff)
downloadgnunet-94f01bdd2fda575769f01f8072689fa6936af8f4.tar.gz
gnunet-94f01bdd2fda575769f01f8072689fa6936af8f4.zip
cleaning argz mess
Diffstat (limited to 'src/util/plugin.c')
-rw-r--r--src/util/plugin.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/util/plugin.c b/src/util/plugin.c
index 36380f339..ca93e9ca0 100644
--- a/src/util/plugin.c
+++ b/src/util/plugin.c
@@ -53,6 +53,12 @@ struct PluginList
53 53
54 54
55/** 55/**
56 * Have we been initialized?
57 */
58static int initialized;
59
60
61/**
56 * Libtool search path before we started. 62 * Libtool search path before we started.
57 */ 63 */
58static char *old_dlsearchpath; 64static char *old_dlsearchpath;
@@ -67,17 +73,14 @@ static struct PluginList *plugins;
67/** 73/**
68 * Setup libtool paths. 74 * Setup libtool paths.
69 */ 75 */
70void __attribute__ ((constructor)) GNUNET_PLUGIN_init () 76static void
77plugin_init ()
71{ 78{
72 int err; 79 int err;
73 const char *opath; 80 const char *opath;
74 char *path; 81 char *path;
75 char *cpath; 82 char *cpath;
76 83
77#ifdef MINGW
78 InitWinEnv (NULL);
79#endif
80
81 err = lt_dlinit (); 84 err = lt_dlinit ();
82 if (err > 0) 85 if (err > 0)
83 { 86 {
@@ -114,7 +117,8 @@ void __attribute__ ((constructor)) GNUNET_PLUGIN_init ()
114/** 117/**
115 * Shutdown libtool. 118 * Shutdown libtool.
116 */ 119 */
117void __attribute__ ((destructor)) GNUNET_PLUGIN_fini () 120static void
121plugin_fini ()
118{ 122{
119 lt_dlsetsearchpath (old_dlsearchpath); 123 lt_dlsetsearchpath (old_dlsearchpath);
120 if (old_dlsearchpath != NULL) 124 if (old_dlsearchpath != NULL)
@@ -122,11 +126,6 @@ void __attribute__ ((destructor)) GNUNET_PLUGIN_fini ()
122 GNUNET_free (old_dlsearchpath); 126 GNUNET_free (old_dlsearchpath);
123 old_dlsearchpath = NULL; 127 old_dlsearchpath = NULL;
124 } 128 }
125
126#ifdef MINGW
127 ShutdownWinEnv ();
128#endif
129
130 lt_dlexit (); 129 lt_dlexit ();
131} 130}
132 131
@@ -173,6 +172,11 @@ GNUNET_PLUGIN_load (const char *library_name, void *arg)
173 GNUNET_PLUGIN_Callback init; 172 GNUNET_PLUGIN_Callback init;
174 void *ret; 173 void *ret;
175 174
175 if (! initialized)
176 {
177 initialized = GNUNET_YES;
178 plugin_init ();
179 }
176 libhandle = lt_dlopenext (library_name); 180 libhandle = lt_dlopenext (library_name);
177 if (libhandle == NULL) 181 if (libhandle == NULL)
178 { 182 {
@@ -235,6 +239,11 @@ GNUNET_PLUGIN_unload (const char *library_name, void *arg)
235 lt_dlclose (pos->handle); 239 lt_dlclose (pos->handle);
236 GNUNET_free (pos->name); 240 GNUNET_free (pos->name);
237 GNUNET_free (pos); 241 GNUNET_free (pos);
242 if (plugins == NULL)
243 {
244 plugin_fini();
245 initialized = GNUNET_NO;
246 }
238 return ret; 247 return ret;
239} 248}
240 249