summaryrefslogtreecommitdiff
path: root/apache1x
diff options
context:
space:
mode:
authorStef Walter <stef@memberwebs.com>2005-09-12 22:49:00 +0000
committerStef Walter <stef@memberwebs.com>2005-09-12 22:49:00 +0000
commit7f02187c64bb175a2f3239358b5848f811846573 (patch)
treee01769bd56ef2ee874c38310c90c7c6e745bf948 /apache1x
parent58a1eaae6e4e1f33117a9462088fc1c2d8b040e8 (diff)
Get httpauth to reconnect properly.
Diffstat (limited to 'apache1x')
-rw-r--r--apache1x/mod_httpauth.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/apache1x/mod_httpauth.c b/apache1x/mod_httpauth.c
index b7023b0..b2d9945 100644
--- a/apache1x/mod_httpauth.c
+++ b/apache1x/mod_httpauth.c
@@ -154,6 +154,19 @@ static const command_rec httpauth_cmds[] =
* Socket handling code
*/
+void disconnect_socket(httpauth_context_t* ctx, server_rec* s)
+{
+ if(ctx->socket != -1)
+ {
+ ap_log_error(APLOG_MARK, APLOG_DEBUG, s,
+ "httpauth: disconnecting from daemon");
+
+ ap_pclosesocket(ctx->child_pool, ctx->socket);
+ ctx->socket = -1;
+ errno = 0;
+ }
+}
+
void read_junk(httpauth_context_t* ctx, request_rec* r)
{
char buf[16];
@@ -245,8 +258,8 @@ int read_line(httpauth_context_t* ctx, request_rec* r, char** line)
/* If it's the end of file then return that */
else if(l == 0)
{
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "httpauth: unexpected end of data from daemon");
+ /* Disconnect from socket quietly so we can reconnect later */
+ disconnect_socket(ctx, r->server);
return -1;
}
@@ -424,19 +437,6 @@ int read_copy_headers(httpauth_context_t* ctx, int ccode, request_rec* r)
return 0;
}
-void disconnect_socket(httpauth_context_t* ctx, server_rec* s)
-{
- if(ctx->socket != -1)
- {
- ap_log_error(APLOG_MARK, APLOG_DEBUG, s,
- "httpauth: disconnecting from daemon");
-
- ap_pclosesocket(ctx->child_pool, ctx->socket);
- ctx->socket = -1;
- errno = 0;
- }
-}
-
int write_data(httpauth_context_t* ctx, server_rec* s, const char* data)
{
int r;
@@ -707,7 +707,8 @@ retry:
read_junk(ctx, r);
/* Send off a request */
- if(write_request(ctx, r) == -1)
+ if(write_request(ctx, r) == -1 ||
+ read_response(ctx, r, &code, &ccode, &details) == -1)
{
/*
* If our connection was closed by httpauthd then this
@@ -718,16 +719,17 @@ retry:
if(ctx->socket == -1 && !retried)
{
+ ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r,
+ "httpauth: reconnecting to to httpauthd");
retried = 1;
goto retry;
}
- return SERVER_ERROR;
- }
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_FROM_OS_ERROR(errno), r,
+ "httpauth: couldn't send request to httpauthd");
- /* Read a response line */
- if(read_response(ctx, r, &code, &ccode, &details) == -1)
- return SERVER_ERROR;
+ return HTTP_INTERNAL_SERVER_ERROR;
+ }
if(code != 200)
{