From: Graham Leggett Date: Fri, 13 Apr 2001 15:30:32 +0000 (+0000) Subject: Fixed all the APR error codes to make sure they end up in the logfiles X-Git-Tag: 2.0.17~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5345c51dbcff31415403e7a5b5dbc7738c3c855d;p=thirdparty%2Fapache%2Fhttpd.git Fixed all the APR error codes to make sure they end up in the logfiles PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88846 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/proxy/proxy_connect.c b/modules/proxy/proxy_connect.c index 9de0fcdf5b0..8db5f3ae53f 100644 --- a/modules/proxy/proxy_connect.c +++ b/modules/proxy/proxy_connect.c @@ -104,13 +104,11 @@ int ap_proxy_connect_handler(request_rec *r, char *url, { apr_pool_t *p = r->pool; apr_socket_t *sock; + apr_status_t err, rv; char buffer[HUGE_STRING_LEN]; - int i, err; + int i; apr_size_t nbytes; -#if 0 - apr_socket_t *client_sock = NULL; -#endif apr_pollfd_t *pollfd; apr_int32_t pollcnt; apr_int16_t pollevent; @@ -193,8 +191,8 @@ int ap_proxy_connect_handler(request_rec *r, char *url, } /* create a new socket */ - if ((apr_socket_create(&sock, APR_INET, SOCK_STREAM, r->pool)) != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + if ((rv = apr_socket_create(&sock, APR_INET, SOCK_STREAM, r->pool)) != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "proxy: error creating socket"); return HTTP_INTERNAL_SERVER_ERROR; } @@ -217,11 +215,11 @@ int ap_proxy_connect_handler(request_rec *r, char *url, while (connect_addr) { /* make the connection out of the socket */ - err = apr_connect(sock, connect_addr); + rv = apr_connect(sock, connect_addr); /* if an error occurred, loop round and try again */ - if (err != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, err, r->server, + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server, "proxy: CONNECT: attempt to connect to %pI (%s) failed", connect_addr, connectname); connect_addr = connect_addr->next; continue; @@ -296,10 +294,10 @@ int ap_proxy_connect_handler(request_rec *r, char *url, /* r->sent_bodyct = 1;*/ - if(apr_poll_setup(&pollfd, 2, r->pool) != APR_SUCCESS) + if((rv = apr_poll_setup(&pollfd, 2, r->pool)) != APR_SUCCESS) { apr_socket_close(sock); - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "proxy: CONNECT: error apr_poll_setup()"); return HTTP_INTERNAL_SERVER_ERROR; } @@ -312,10 +310,10 @@ int ap_proxy_connect_handler(request_rec *r, char *url, while (1) { /* Infinite loop until error (one side closes the connection) */ /* ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server, "proxy: CONNECT: going to sleep (poll)");*/ - if (apr_poll(pollfd, &pollcnt, -1) != APR_SUCCESS) + if ((rv = apr_poll(pollfd, &pollcnt, -1)) != APR_SUCCESS) { apr_socket_close(sock); - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "proxy: CONNECT: error apr_poll()"); + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "proxy: CONNECT: error apr_poll()"); return HTTP_INTERNAL_SERVER_ERROR; } /* ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server, diff --git a/modules/proxy/proxy_ftp.c b/modules/proxy/proxy_ftp.c index 6f5937dc1f2..06e7f815366 100644 --- a/modules/proxy/proxy_ftp.c +++ b/modules/proxy/proxy_ftp.c @@ -633,24 +633,24 @@ int ap_proxy_ftp_handler(request_rec *r, char *url) } - if ((apr_socket_create(&sock, APR_INET, SOCK_STREAM, r->pool)) != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + if ((rv = apr_socket_create(&sock, APR_INET, SOCK_STREAM, r->pool)) != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "proxy: FTP: error creating socket"); return HTTP_INTERNAL_SERVER_ERROR; } #if !defined(TPF) && !defined(BEOS) if (conf->recv_buffer_size > 0 - && apr_setsocketopt(sock, APR_SO_RCVBUF, - conf->recv_buffer_size)) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + && (rv = apr_setsocketopt(sock, APR_SO_RCVBUF, + conf->recv_buffer_size))) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "setsockopt(SO_RCVBUF): Failed to set ProxyReceiveBufferSize, using default"); } #endif - if (apr_setsocketopt(sock, APR_SO_REUSEADDR, one)) { + if (APR_SUCCESS != (rv = apr_setsocketopt(sock, APR_SO_REUSEADDR, one))) { #ifndef _OSD_POSIX /* BS2000 has this option "always on" */ - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "proxy: FTP: error setting reuseaddr option: setsockopt(SO_REUSEADDR)"); return HTTP_INTERNAL_SERVER_ERROR; #endif /*_OSD_POSIX*/ @@ -678,11 +678,11 @@ int ap_proxy_ftp_handler(request_rec *r, char *url) while (connect_addr) { /* make the connection out of the socket */ - err = apr_connect(sock, connect_addr); + rv = apr_connect(sock, connect_addr); /* if an error occurred, loop round and try again */ - if (err != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, err, r->server, + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server, "proxy: FTP: attempt to connect to %pI (%s) failed", connect_addr, connectname); connect_addr = connect_addr->next; continue; @@ -1131,8 +1131,8 @@ int ap_proxy_ftp_handler(request_rec *r, char *url) apr_port_t local_port; unsigned int h0, h1, h2, h3, p0, p1; - if ((apr_socket_create(&local_sock, APR_INET, SOCK_STREAM, r->pool)) != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + if ((rv = apr_socket_create(&local_sock, APR_INET, SOCK_STREAM, r->pool)) != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "proxy: FTP: error creating local socket"); return HTTP_INTERNAL_SERVER_ERROR; } @@ -1140,29 +1140,28 @@ int ap_proxy_ftp_handler(request_rec *r, char *url) apr_sockaddr_port_get(&local_port, local_addr); apr_sockaddr_ip_get(&local_ip, local_addr); - if (apr_setsocketopt(local_sock, APR_SO_REUSEADDR, one) != APR_SUCCESS) { + if ((rv = apr_setsocketopt(local_sock, APR_SO_REUSEADDR, one)) != APR_SUCCESS) { #ifndef _OSD_POSIX /* BS2000 has this option "always on" */ - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "proxy: FTP: error setting reuseaddr option"); return HTTP_INTERNAL_SERVER_ERROR; #endif /*_OSD_POSIX*/ } - if (apr_sockaddr_info_get(&local_addr, local_ip, APR_UNSPEC, - local_port, 0, r->pool) != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, - "proxy: FTP: error creating local socket address"); - return HTTP_INTERNAL_SERVER_ERROR; - } + apr_sockaddr_info_get(&local_addr, local_ip, APR_UNSPEC, local_port, 0, r->pool); - if (apr_bind(local_sock, local_addr) != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, - "proxy: FTP: error binding to ftp data socket %s:%d", local_ip, local_port); + if ((rv = apr_bind(local_sock, local_addr)) != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + "proxy: FTP: error binding to ftp data socket %pI", local_addr); return HTTP_INTERNAL_SERVER_ERROR; } /* only need a short queue */ - apr_listen(local_sock, 2); + if ((rv = apr_listen(local_sock, 2)) != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, + "proxy: FTP: error listening to ftp data socket %pI", local_addr); + return HTTP_INTERNAL_SERVER_ERROR; + } /* FIXME: Sent PORT here */ @@ -1473,8 +1472,8 @@ int ap_proxy_ftp_handler(request_rec *r, char *url) "proxy: FTP: Content-Length set to %s", size); } } -ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server, - "proxy: FTP: Content-Type set to %s", r->content_type); + ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server, + "proxy: FTP: Content-Type set to %s", r->content_type); if (r->content_encoding != NULL && r->content_encoding[0] != '\0') { ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server, "proxy: FTP: Content-Encoding set to %s", r->content_encoding); @@ -1486,14 +1485,14 @@ ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server, for(;;) { /* FIXME: this does not return, despite the incoming connection being accepted */ - switch(apr_accept(&remote_sock, local_sock, r->pool)) + switch(rv = apr_accept(&remote_sock, local_sock, r->pool)) { case APR_EINTR: continue; case APR_SUCCESS: break; default: - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "proxy: FTP: failed to accept data connection"); return HTTP_BAD_GATEWAY; } diff --git a/modules/proxy/proxy_http.c b/modules/proxy/proxy_http.c index 27387c99858..5fd9f92a0b4 100644 --- a/modules/proxy/proxy_http.c +++ b/modules/proxy/proxy_http.c @@ -334,16 +334,16 @@ int ap_proxy_http_handler(request_rec *r, char *url, backend->connection = NULL; /* see memory note above */ - if ((apr_socket_create(&sock, APR_INET, SOCK_STREAM, c->pool)) != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server, + if ((rv = apr_socket_create(&sock, APR_INET, SOCK_STREAM, c->pool)) != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server, "proxy: error creating socket"); return HTTP_INTERNAL_SERVER_ERROR; } #if !defined(TPF) && !defined(BEOS) - if (conf->recv_buffer_size > 0 && apr_setsocketopt(sock, APR_SO_RCVBUF, - conf->recv_buffer_size)) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + if (conf->recv_buffer_size > 0 && (rv = apr_setsocketopt(sock, APR_SO_RCVBUF, + conf->recv_buffer_size))) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "setsockopt(SO_RCVBUF): Failed to set ProxyReceiveBufferSize, using default"); } #endif @@ -368,11 +368,11 @@ int ap_proxy_http_handler(request_rec *r, char *url, while (connect_addr) { /* make the connection out of the socket */ - err = apr_connect(sock, connect_addr); + rv = apr_connect(sock, connect_addr); /* if an error occurred, loop round and try again */ - if (err != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_ERR, err, r->server, + if (rv != APR_SUCCESS) { + ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server, "proxy: attempt to connect to %pI (%s) failed", connect_addr, connectname); connect_addr = connect_addr->next; @@ -590,7 +590,7 @@ int ap_proxy_http_handler(request_rec *r, char *url, if (APR_SUCCESS != (rv = ap_proxy_string_read(origin, bb, buffer, sizeof(buffer), &eos))) { apr_socket_close(sock); backend->connection = NULL; - ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, + ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "proxy: error reading status line from remote server %s", connectname); return ap_proxyerror(r, HTTP_BAD_GATEWAY,