diff options
author | Stef Walter <stef@memberwebs.com> | 2005-09-12 22:49:00 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2005-09-12 22:49:00 +0000 |
commit | 7f02187c64bb175a2f3239358b5848f811846573 (patch) | |
tree | e01769bd56ef2ee874c38310c90c7c6e745bf948 /apache2x | |
parent | 58a1eaae6e4e1f33117a9462088fc1c2d8b040e8 (diff) |
Get httpauth to reconnect properly.
Diffstat (limited to 'apache2x')
-rw-r--r-- | apache2x/mod_httpauth.c | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/apache2x/mod_httpauth.c b/apache2x/mod_httpauth.c index c6d6e56..b225e5b 100644 --- a/apache2x/mod_httpauth.c +++ b/apache2x/mod_httpauth.c @@ -155,6 +155,26 @@ static const command_rec httpauth_cmds[] = * Socket handling code */ +static apr_status_t cleanup_socket(void *fdv) +{ + close((int)(long)fdv); + return OK; +} + +void disconnect_socket(httpauth_context_t* ctx, server_rec* s) +{ + if(ctx->socket != -1) + { + ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, + "httpauth: disconnecting from daemon"); + + apr_pool_cleanup_kill(ctx->child_pool, (void*)(long)ctx->socket, + cleanup_socket); + close(ctx->socket); + ctx->socket = -1; + } +} + void read_junk(httpauth_context_t* ctx, request_rec* r) { char buf[16]; @@ -245,8 +265,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, 0, r, - "httpauth: unexpected end of data from daemon"); + /* Disconnect from socket quietly so we can reconnect later */ + disconnect_socket(ctx, r->server); return -1; } @@ -423,27 +443,6 @@ int read_copy_headers(httpauth_context_t* ctx, int ccode, request_rec* r) return 0; } - -static apr_status_t cleanup_socket(void *fdv) -{ - close((int)(long)fdv); - return OK; -} - -void disconnect_socket(httpauth_context_t* ctx, server_rec* s) -{ - if(ctx->socket != -1) - { - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, - "httpauth: disconnecting from daemon"); - - apr_pool_cleanup_kill(ctx->child_pool, (void*)(long)ctx->socket, - cleanup_socket); - close(ctx->socket); - ctx->socket = -1; - } -} - int write_data(httpauth_context_t* ctx, server_rec* s, const char* data) { int r; @@ -716,7 +715,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 @@ -727,16 +727,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 HTTP_INTERNAL_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 HTTP_INTERNAL_SERVER_ERROR; + } if(code != 200) { |