Navigation Menu

Skip to content

Commit

Permalink
Fix log environ leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mopemope committed Sep 15, 2012
1 parent e40b583 commit a269a1e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
6 changes: 3 additions & 3 deletions example/hello_world.py
Expand Up @@ -5,12 +5,12 @@ def hello_world(environ, start_response):
res = b"Hello world!"
response_headers = [('Content-type','text/plain')]
start_response(status, response_headers)
print(environ)
#print(environ)
return [res]

server.listen(("0.0.0.0", 8000))
# server.access_log('stdout')
#server.error_log('/tmp/err.log')
server.set_access_logger(None)
server.set_error_logger(None)
server.run(hello_world)


22 changes: 18 additions & 4 deletions meinheld/server/server.c
Expand Up @@ -191,23 +191,27 @@ set_log_value(client_t *client, PyObject *environ, uintptr_t delta_msec)

if(status_code){
PyDict_SetItem(environ, status_code_key, status_code);
Py_DECREF(status_code);
}

if(bytes){
PyDict_SetItem(environ, bytes_sent_key, bytes);
Py_DECREF(bytes);
}

if(request_time){
PyDict_SetItem(environ, request_time_key, request_time);
Py_DECREF(request_time);
}

if(local_time){
PyDict_SetItem(environ, local_time_key, local_time);
Py_DECREF(local_time);
}

}

static void
static void
clean_client(client_t *client)
{
PyObject *environ = NULL;
Expand Down Expand Up @@ -1402,10 +1406,15 @@ meinheld_access_log(PyObject *self, PyObject *args)
PyObject *o = NULL;
PyObject *func = NULL;

if (!PyArg_ParseTuple(args, "O:access_log", &o)){
if (!PyArg_ParseTuple(args, "O:access_logger", &o)){
return NULL;
}


if(o == Py_None){
set_access_logger(NULL);
Py_RETURN_NONE;
}

func = PyObject_GetAttrString(o, "access");
if(func == NULL){
return NULL;
Expand All @@ -1425,10 +1434,15 @@ meinheld_error_log(PyObject *self, PyObject *args)
PyObject *o = NULL;
PyObject *func = NULL;

if (!PyArg_ParseTuple(args, "O:err_log", &o)){
if (!PyArg_ParseTuple(args, "O:error_logger", &o)){
return NULL;
}

if(o == Py_None){
set_err_logger(NULL);
Py_RETURN_NONE;
}

func = PyObject_GetAttrString(o, "error");
if(func == NULL){
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -82,7 +82,7 @@ def get_sources(path, ignore_files):
author_email='yutaka.matsubara@gmail.com',
url='http://meinheld.org',
license='BSD',
platforms='Linux, Darwin',
platforms='Linux, BSD, Darwin',
packages= ['meinheld'],
install_requires=install_requires,

Expand Down

0 comments on commit a269a1e

Please sign in to comment.