mirror of
https://github.com/lxsang/ant-http
synced 2024-11-17 17:08:20 +01: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"
|
||||
static pthread_mutex_t server_mux = PTHREAD_MUTEX_INITIALIZER;
|
||||
/**********************************************************************/
|
||||
/* A request has caused a call to accept() on the server port to
|
||||
* return. Process the request appropriately.
|
||||
@ -958,11 +959,16 @@ int execute_plugin(void* client, const char *path, const char *method, dictionar
|
||||
|
||||
//load the plugin
|
||||
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);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
// load the function
|
||||
fn = (void (*)(void*, const char *, const char*, dictionary))dlsym(plugin->handle, PLUGIN_HANDLER);
|
||||
if ((error = dlerror()) != NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user