summaryrefslogtreecommitdiff
path: root/apache1x/mod_httpauth.c
diff options
context:
space:
mode:
Diffstat (limited to 'apache1x/mod_httpauth.c')
-rw-r--r--apache1x/mod_httpauth.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/apache1x/mod_httpauth.c b/apache1x/mod_httpauth.c
index 91e6288..4b1abe6 100644
--- a/apache1x/mod_httpauth.c
+++ b/apache1x/mod_httpauth.c
@@ -141,7 +141,7 @@ void read_junk(httpauth_context_t* ctx, request_rec* r)
break;
buf[l] = 0;
- t = trim_start(t);
+ t = trim_start(buf);
if(!said && *t)
{
@@ -651,6 +651,7 @@ static int httpauth_authenticate(request_rec* r)
int ccode = 0;
char* details = NULL;
request_rec* mainreq;
+ int retried = 0;
/* Make sure it's for us */
if(!(authtype = ap_auth_type(r)) || strcasecmp(HTTPAUTH_AUTHTYPE, authtype) != 0)
@@ -674,6 +675,9 @@ static int httpauth_authenticate(request_rec* r)
if(ap_get_module_config(mainreq->request_config, &httpauth_module))
return OK;
+/* For jumping to when a connection has been closed */
+retry:
+
if(ctx->socket == -1)
{
if(connect_httpauth(ctx, r) == -1)
@@ -685,7 +689,22 @@ static int httpauth_authenticate(request_rec* r)
/* Send off a request */
if(write_request(ctx, r) == -1)
+ {
+ /*
+ * If our connection was closed by httpauthd then this
+ * is where we get the error. Just do one retry to
+ * try and reconnect. This happens often when restarting
+ * httpauthd.
+ */
+
+ if(ctx->socket == -1 && !retried)
+ {
+ retried = 1;
+ goto retry;
+ }
+
return SERVER_ERROR;
+ }
/* Read a response line */
if(read_response(ctx, r, &code, &ccode, &details) == -1)