|
@@ -92,24 +92,31 @@ int work333(int wrk_id, int semid)
|
92
|
92
|
libpyfcgi.out = out_stream;
|
93
|
93
|
args = Py_BuildValue("OO", environ, start_response);
|
94
|
94
|
entry_ret = PyObject_CallObject(entry_fun, args);
|
95
|
|
- Py_INCREF(entry_ret);
|
|
95
|
+ if(entry_ret && entry_ret != Py_None )
|
|
96
|
+ {
|
|
97
|
+ Py_INCREF(entry_ret);
|
|
98
|
+ }
|
96
|
99
|
|
97
|
100
|
if(PyErr_Occurred())
|
98
|
101
|
{
|
|
102
|
+ pyfcgi_log(LOG_ERR, "PEP333 entrypoint function triggered an exception");
|
99
|
103
|
log_expt(LOG_ERR);
|
100
|
104
|
}
|
101
|
105
|
// able to process returned value
|
102
|
106
|
// Simulate python call of libpyfcgi.write_body()
|
103
|
|
- _pyfcgi_write_body(entry_ret);
|
104
|
|
- if(PyErr_Occurred())
|
|
107
|
+ if(entry_ret && entry_ret != Py_None)
|
105
|
108
|
{
|
106
|
|
- log_expt(LOG_ERR);
|
|
109
|
+ _pyfcgi_write_body(entry_ret);
|
|
110
|
+ if(PyErr_Occurred())
|
|
111
|
+ {
|
|
112
|
+ log_expt(LOG_ERR);
|
|
113
|
+ }
|
|
114
|
+ Py_DECREF(entry_ret);
|
107
|
115
|
}
|
108
|
116
|
|
109
|
117
|
// clean stuffs
|
110
|
118
|
Py_DECREF(args);
|
111
|
119
|
Py_DECREF(environ);
|
112
|
|
- Py_DECREF(entry_ret);
|
113
|
120
|
// flush & logs pystdout & pystderr
|
114
|
121
|
PyObject_CallObject(pyflush[0], NULL);
|
115
|
122
|
PyObject_CallObject(pyflush[1], NULL);
|