Bug 57685 - Requests are denied while the mod_cgid daemon starts up
Summary: Requests are denied while the mod_cgid daemon starts up
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_cgid (show other bugs)
Version: 2.5-HEAD
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: FixedInTrunk, PatchAvailable
Depends on:
Blocks:
 
Reported: 2015-03-10 19:36 UTC by Edward Lu
Modified: 2017-05-25 12:22 UTC (History)
0 users



Attachments
Delay cgi requests made before the cgid daemon has started (1.71 KB, patch)
2015-03-10 19:36 UTC, Edward Lu
Details | Diff
Delay cgi requests made before the cgid daemon has started (2.08 KB, patch)
2015-03-16 15:27 UTC, Edward Lu
Details | Diff
Delay cgi requests made before the cgid daemon has started (2.56 KB, patch)
2015-03-16 17:22 UTC, Edward Lu
Details | Diff
Delay cgi requests made before the cgid daemon has started (3.07 KB, patch)
2015-03-16 18:07 UTC, Edward Lu
Details | Diff
Delay cgi requests made before the cgid daemon has started (2.74 KB, patch)
2015-03-16 18:14 UTC, Edward Lu
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Edward Lu 2015-03-10 19:36:12 UTC
Created attachment 32555 [details]
Delay cgi requests made before the cgid daemon has started

There is a short interval where httpd has started up and is accepting requests, but the cgid daemon has not yet created a listening socket. In this interval, any cgi requests made will receive a 503 response. While that response is technically correct, it seems like a retry system could be more appropriate.
Comment 1 Edward Lu 2015-03-16 15:27:43 UTC
Created attachment 32577 [details]
Delay cgi requests made before the cgid daemon has started

Rebased the patch onto trunk. Also made it not retry if the socket somehow goes away.
Comment 2 Yann Ylavic 2015-03-16 15:57:41 UTC
(In reply to Edward Lu from comment #1)
> Rebased the patch onto trunk. Also made it not retry if the socket somehow
> goes away.

You probably need to save errno after connect() and use that value in late checks.
Comment 3 Edward Lu 2015-03-16 17:22:49 UTC
Created attachment 32578 [details]
Delay cgi requests made before the cgid daemon has started

Good point. The errno currently isn't being saved in trunk, but it's being used only in the log; I guess since we're using it for more in this patch, it's better to be safe.
Comment 4 Yann Ylavic 2015-03-16 17:44:53 UTC
Maybe declare connect_errno = 0 in the loop block so that it is initialized when connect() succeeds?
Comment 5 Edward Lu 2015-03-16 18:07:02 UTC
Created attachment 32579 [details]
Delay cgi requests made before the cgid daemon has started

Done.
Comment 6 Edward Lu 2015-03-16 18:14:16 UTC
Created attachment 32580 [details]
Delay cgi requests made before the cgid daemon has started

Forgot to take out a call to sleep I was using while testing. Sorry about all the revision spam.
Comment 7 Eric Covener 2015-03-17 20:14:09 UTC
Thanks Ed and Yann, committed with minor tweaks in r1667385
Comment 8 Brad Newman 2015-05-19 17:51:08 UTC
I encountered this problem with httpd 2.4.9, and tried the patch.  

Unfortunately, the 503 responses with the same "(2)No such file or directory: AH01257: unable to connect to cgi daemon after multiple tries" error also happen after a *graceful* restart of httpd.  

But the graceful restarts don't reset the scoreboard's restart_time, so if httpd has been running for more than a minute when the graceful restart occurs, we end up in the APLOGNO(02831) branch and don't benefit from any retries.
Comment 9 Christophe JAILLET 2017-05-25 12:22:16 UTC
This has been merged in 2.4.x in r1669559.

Is is part of 2.4.13