Skip to content
This repository has been archived by the owner on Jun 24, 2023. It is now read-only.

Commit

Permalink
[python] protecting sub-interpreter deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Jun 11, 2015
1 parent 1421af6 commit 5faaa31
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion plugin-python.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,16 @@ int proxenet_python_initialize_vm(plugin_t* plugin)
*/
int proxenet_python_destroy_plugin(plugin_t* plugin)
{
PyThreadState* oldctx;

plugin->state = INACTIVE;
Py_DECREF(plugin->pre_function);
Py_DECREF(plugin->post_function);

oldctx = PyThreadState_Get();
PyThreadState_Swap( plugin->internal );
Py_EndInterpreter( plugin->internal );
PyThreadState_Swap( oldctx );

return 0;
}
Expand Down Expand Up @@ -269,7 +275,7 @@ int proxenet_python_load_file(plugin_t* plugin)

if (proxenet_python_initialize_function(plugin, REQUEST) < 0 || \
proxenet_python_initialize_function(plugin, RESPONSE) < 0) {
xlog_python(LOG_ERROR, "Failed to initialize '%s.%s'\n", plugin->name
xlog_python(LOG_ERROR, "Failed to initialize '%s.%s'\n", plugin->name,
REQUEST ? CFG_REQUEST_PLUGIN_FUNCTION : CFG_RESPONSE_PLUGIN_FUNCTION);
retcode = -1;
}
Expand Down
2 changes: 1 addition & 1 deletion proxenet-plugins

0 comments on commit 5faaa31

Please sign in to comment.