From b70e2d0ef64738561685072f01f7b3181fc89c69 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 6 Jul 2004 19:53:55 +0000 Subject: - Nicer reconnect support - Fixed other small bugs --- apache1x/mod_httpauth.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'apache1x/mod_httpauth.c') 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) -- cgit v1.2.3