Project

General

Profile

Actions

Bug #3157

closed

fall-back with cgi error handler no longer works

Added by sparlane almost 2 years ago. Updated almost 2 years ago.

Status:
Fixed
Priority:
Normal
Category:
mod_cgi
Target version:
ASK QUESTIONS IN Forums:
No

Description

Regression point dd23fcb2b23b2e7ba337b5e31301368214088000

Config:
mod_cgi and server.error-handler = "/cgi-bin/error.lua"

Previously, if error.lua had no output to stdout and returned 0, the default error handling code would run.

Our error.lua only does/prints anything if the current status code is 401 and only for specific paths,
otherwise it will print nothing and return 0.

Since the regression point, when a 404 would occur, lighttpd never sends any response to the client
The same also happens if /cgi-bin/error.lua is accessed directly

Actions #1

Updated by gstrauss almost 2 years ago

Thank you for tracking down the problem commit.

There does appear to be an issue in the current behavior. At the same time, I am not yet sure whether or not the full behavior you expect from server.error-handler is correct. I'll look into it more this week.

Actions #2

Updated by gstrauss almost 2 years ago

  • Status changed from New to Patch Pending
  • Target version changed from 1.4.xx to 1.4.65

Please see if this works for you:

--- a/src/mod_cgi.c
+++ b/src/mod_cgi.c
@@ -639,6 +639,7 @@ static handler_t cgi_process_rd_revents(handler_ctx * const hctx, request_st * c
                        if (0 == r->http_status) r->http_status = 200; /* OK */
                }
                cgi_connection_close(hctx);
+               return HANDLER_FINISHED;
        } else if (revents & FDEVENT_ERR) {
                /* kill all connections to the cgi process */
                cgi_connection_close(hctx);

Actions #3

Updated by sparlane almost 2 years ago

Hi,

Yes this works (no infinite stall) and restores the previous behaviour wrt error handling fall-thru.

Thanks.

Actions #4

Updated by gstrauss almost 2 years ago

Thanks for confirming. As you identified, this was a bug in commit dd23fcb2

BTW, instead of server.error-handler, you might want to take a peek at mod_magnet magnet.attract-response-start-to where you can run your error.lua directly within lighttpd, and do what you need to do if lighty.r.req_item.http_status == 401 (lighttpd 1.4.65) (or, in current lighttpd release, the to-be-deprecated-with-lighttpd-1.4.65: lighty.r.req_attr["http-status"] == 401 )

Actions #5

Updated by gstrauss almost 2 years ago

  • Status changed from Patch Pending to Fixed
Actions

Also available in: Atom