diff options
author | Jim Jagielski <jim@apache.org> | 2006-01-02 16:52:58 +0000 |
---|---|---|
committer | Jim Jagielski <jim@apache.org> | 2006-01-02 16:52:58 +0000 |
commit | 708752821b1de86760ba1bbcb7cecf43bc1e70e3 (patch) | |
tree | f85eb468c422d3bb986e9b6db09a11b09f84a018 | |
parent | 1b22034fb20a18b030ac74500550d02da6001ce7 (diff) | |
download | httpd-708752821b1de86760ba1bbcb7cecf43bc1e70e3.tar.gz |
Avoid magic numbers. Since we are reading the header, let's
be explicit about it. Also removes the need to clean up
the readbuf again, and any potential for confusion on
what we are doing ;)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/fcgi-proxy-dev@365376 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | modules/proxy/mod_proxy_fcgi.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/modules/proxy/mod_proxy_fcgi.c b/modules/proxy/mod_proxy_fcgi.c index 2d8d83c6e5..fef8874ed9 100644 --- a/modules/proxy/mod_proxy_fcgi.c +++ b/modules/proxy/mod_proxy_fcgi.c @@ -454,25 +454,27 @@ static apr_status_t dispatch(proxy_conn_rec *conn, request_rec *r, int rid, type = 0; char plen = 0; apr_bucket *b; + fcgi_header rheader; + int rheader_size = sizeof(fcgi_header); memset(readbuf, 0, sizeof(readbuf)); /* First, we grab the header... */ - readbuflen = 8; + readbuflen = rheader_size; - rv = apr_socket_recv(conn->sock, readbuf, &readbuflen); + rv = apr_socket_recv(conn->sock, (char *)&rheader, &readbuflen); if (rv != APR_SUCCESS) { break; } - if (readbuflen != 8) { + if (readbuflen != rheader_size) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "proxy: FCGI: Failed to read entire header"); rv = APR_EINVAL; break; } - if (readbuf[0] != FCGI_VERSION) { + if (rheader.version != FCGI_VERSION) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, "proxy: FCGI: Got bogus version %d", (int) readbuf[0]); @@ -480,10 +482,10 @@ static apr_status_t dispatch(proxy_conn_rec *conn, request_rec *r, break; } - type = readbuf[1]; + type = rheader.type; - rid |= readbuf[2] << 8; - rid |= readbuf[3] << 0; + rid |= rheader.requestIdB1 << 8; + rid |= rheader.requestIdB0 << 0; if (rid != request_id) { ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, @@ -493,13 +495,10 @@ static apr_status_t dispatch(proxy_conn_rec *conn, request_rec *r, break; } - clen |= readbuf[4] << 8; - clen |= readbuf[5] << 0; + clen |= rheader.contentLengthB1 << 8; + clen |= rheader.contentLengthB0 << 0; - plen = readbuf[6]; - - /* Clear out the header so our buffer is zeroed out again */ - memset(readbuf, 0, 8); + plen = rheader.paddingLength; recv_again: if (clen > sizeof(readbuf) - 1) { |