mirror of
https://github.com/lxsang/ant-http
synced 2025-04-17 16:16:45 +02:00
fix bug: two threads load a same plugin as the same time
This commit is contained in:
parent
4679f6ab04
commit
f2a2139e5b
@ -1,4 +1,5 @@
|
|||||||
#include "http_server.h"
|
#include "http_server.h"
|
||||||
|
static pthread_mutex_t server_mux = PTHREAD_MUTEX_INITIALIZER;
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
/* A request has caused a call to accept() on the server port to
|
/* A request has caused a call to accept() on the server port to
|
||||||
* return. Process the request appropriately.
|
* return. Process the request appropriately.
|
||||||
@ -958,11 +959,16 @@ int execute_plugin(void* client, const char *path, const char *method, dictionar
|
|||||||
|
|
||||||
//load the plugin
|
//load the plugin
|
||||||
if((plugin = plugin_lookup(pname)) == NULL)
|
if((plugin = plugin_lookup(pname)) == NULL)
|
||||||
if((plugin= plugin_load(pname)) == NULL)
|
{
|
||||||
|
pthread_mutex_lock(&server_mux);
|
||||||
|
plugin= plugin_load(pname);
|
||||||
|
pthread_mutex_unlock(&server_mux);
|
||||||
|
if( plugin == NULL)
|
||||||
{
|
{
|
||||||
if(orgs) free(orgs);
|
if(orgs) free(orgs);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// load the function
|
// load the function
|
||||||
fn = (void (*)(void*, const char *, const char*, dictionary))dlsym(plugin->handle, PLUGIN_HANDLER);
|
fn = (void (*)(void*, const char *, const char*, dictionary))dlsym(plugin->handle, PLUGIN_HANDLER);
|
||||||
if ((error = dlerror()) != NULL)
|
if ((error = dlerror()) != NULL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user