Permalink
Browse files

Fixes bug #676. The server was crashing whenever PHP (via fastcgi)

tried to log an error message: http://bugs.cherokee-project.com/676

git-svn-id: svn://cherokee-project.com/cherokee/trunk@4017 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
alobbs committed Dec 16, 2009
1 parent 6defe69 commit 97945bfa338ee5ab40cfd236dc815d219d1b60eb
Showing with 48 additions and 17 deletions.
  1. +6 −7 cherokee/handler_fcgi.c
  2. +21 −4 cherokee/server.c
  3. +21 −6 cherokee/thread.c
View
@@ -59,9 +59,8 @@ CGI_LIB_INIT (fcgi, http_all_methods);
static ret_t
process_package (cherokee_handler_fcgi_t *hdl, cherokee_buffer_t *inbuf, cherokee_buffer_t *outbuf)
{
- FCGI_Header *header;
- FCGI_EndRequestBody *ending;
- cherokee_connection_t *conn = HANDLER_CONN(hdl);
+ FCGI_Header *header;
+ FCGI_EndRequestBody *ending;
cuint_t len;
char *data;
@@ -116,10 +115,10 @@ process_package (cherokee_handler_fcgi_t *hdl, cherokee_buffer_t *inbuf, cheroke
case FCGI_STDERR:
/* printf ("READ:STDERR (%d): %s", len, data?data:""); */
- if (CONN_VSRV(conn)->logger != NULL) {
- LOG_ERROR (CHEROKEE_ERROR_HANDLER_FCGI_STDERR, data);
- }
- else if (SOURCE_INT(hdl->src_ref)->debug) {
+ LOG_ERROR (CHEROKEE_ERROR_HANDLER_FCGI_STDERR, data);
+
+ /* Debug mode */
+ if (SOURCE_INT(hdl->src_ref)->debug) {
PRINT_MSG ("%.*s\n", len, data);
}
View
@@ -656,13 +656,30 @@ initialize_server_threads (cherokee_server_t *srv)
static ret_t
initialize_loggers (cherokee_server_t *srv)
{
- ret_t ret;
- cherokee_list_t *i;
- cherokee_logger_t *logger;
+ ret_t ret;
+ cherokee_list_t *i;
- /* Initialize all the loggers
+ /* Initialize the error writers
*/
list_for_each (i, &srv->vservers) {
+ cherokee_logger_writer_t *writer;
+
+ writer = VSERVER(i)->error_writer;
+ if (writer == NULL) {
+ continue;
+ }
+
+ ret = cherokee_logger_writer_open (writer);
+ if (ret != ret_ok) {
+ return ret;
+ }
+ }
+
+ /* Initialize loggers as well
+ */
+ list_for_each (i, &srv->vservers) {
+ cherokee_logger_t *logger;
+
logger = VSERVER(i)->logger;
if (logger == NULL) {
continue;
View
@@ -515,9 +515,14 @@ process_polling_connections (cherokee_thread_t *thd)
list_for_each_safe (i, tmp, LIST(&thd->polling_list)) {
conn = CONN(i);
- /* Thread logger
+ /* Thread's error logger
*/
- CHEROKEE_THREAD_PROP_SET (thread_error_writer_ptr, conn->logger_ref);
+ if (CONN_VSRV(conn) &&
+ CONN_VSRV(conn)->error_writer)
+ {
+ CHEROKEE_THREAD_PROP_SET (thread_error_writer_ptr,
+ CONN_VSRV(conn)->error_writer);
+ }
/* Has it been too much without any work?
*/
@@ -597,9 +602,14 @@ process_active_connections (cherokee_thread_t *thd)
TRACE (ENTRIES, "thread (%p) processing conn (%p), phase %d '%s'\n",
thd, conn, conn->phase, cherokee_connection_get_phase_str (conn));
- /* Thread logger
+ /* Thread's error logger
*/
- CHEROKEE_THREAD_PROP_SET (thread_error_writer_ptr, conn->logger_ref);
+ if (CONN_VSRV(conn) &&
+ CONN_VSRV(conn)->error_writer)
+ {
+ CHEROKEE_THREAD_PROP_SET (thread_error_writer_ptr,
+ CONN_VSRV(conn)->error_writer);
+ }
/* Has the connection been too much time w/o any work
*/
@@ -882,9 +892,14 @@ process_active_connections (cherokee_thread_t *thd)
continue;
}
- /* Thread logger
+ /* Thread's error logger
*/
- CHEROKEE_THREAD_PROP_SET (thread_error_writer_ptr, conn->logger_ref);
+ if (CONN_VSRV(conn) &&
+ CONN_VSRV(conn)->error_writer)
+ {
+ CHEROKEE_THREAD_PROP_SET (thread_error_writer_ptr,
+ CONN_VSRV(conn)->error_writer);
+ }
/* Information collection
*/

0 comments on commit 97945bf

Please sign in to comment.