From acdd69c7ba1120ba36ba0899310b592e664c44f2 Mon Sep 17 00:00:00 2001 From: edson-a-soares Date: Mon, 16 Oct 2017 16:38:36 -0300 Subject: [PATCH 1/3] Fix ".. has no member named ... compile error" by renaming apache conn_rec attributes - conn_rec attributes remote_ip and remote_addr were replaced by client_ip and client_addr once they have been renamed in Apache 2.4 - a server_rec pointer must be passed to ap_log_error() since apache 2.4, therefore, a change was necessary at the ap_log_error log function. A null pointer has been passed for avoiding deeper changes at the function. - the smart pointer auto_ptr was replaced by unique_ptr once it was made deprecated in C++11 standard, it has been replaced by unique_ptr. --- ApacheConnector/src/ApacheConnector.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ApacheConnector/src/ApacheConnector.cpp b/ApacheConnector/src/ApacheConnector.cpp index b656f8e24d..474b28d6b9 100644 --- a/ApacheConnector/src/ApacheConnector.cpp +++ b/ApacheConnector/src/ApacheConnector.cpp @@ -149,7 +149,7 @@ void ApacheRequestRec::copyHeaders(ApacheServerRequest& request) void ApacheConnector::log(const char* file, int line, int level, int status, const char *text) { - ap_log_error(file, line, level, 0, NULL, "%s", text); + ap_log_error(file, line, level, 0, NULL, 0, text); } @@ -172,21 +172,21 @@ extern "C" int ApacheConnector_handler(request_rec *r) if ((rv = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK))) return rv; - std::auto_ptr pRequest(new ApacheServerRequest( + std::unique_ptr pRequest(new ApacheServerRequest( &rec, r->connection->local_ip, r->connection->local_addr->port, - r->connection->remote_ip, - r->connection->remote_addr->port)); + r->connection->client_ip, + r->connection->client_addr->port)); - std::auto_ptr pResponse(new ApacheServerResponse(pRequest.get())); + std::unique_ptr pResponse(new ApacheServerResponse(pRequest.get())); // add header information to request rec.copyHeaders(*pRequest); try { - std::auto_ptr pHandler(app.factory().createRequestHandler(*pRequest)); + std::unique_ptr pHandler(app.factory().createRequestHandler(*pRequest)); if (pHandler.get()) { From da6d3df84d9a1042deabd37fd12012e390caa654 Mon Sep 17 00:00:00 2001 From: edson-a-soares Date: Tue, 17 Oct 2017 13:30:08 -0300 Subject: [PATCH 2/3] Add the properly #ifdef directives for backward compatibility purposes - Adding proper #ifdef preprocessor directives to keeping backward compatibility with older apache versions. --- ApacheConnector/src/ApacheConnector.cpp | 35 ++++++++++++++++++------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/ApacheConnector/src/ApacheConnector.cpp b/ApacheConnector/src/ApacheConnector.cpp index 474b28d6b9..f93caaab27 100644 --- a/ApacheConnector/src/ApacheConnector.cpp +++ b/ApacheConnector/src/ApacheConnector.cpp @@ -149,7 +149,13 @@ void ApacheRequestRec::copyHeaders(ApacheServerRequest& request) void ApacheConnector::log(const char* file, int line, int level, int status, const char *text) { - ap_log_error(file, line, level, 0, NULL, 0, text); + // ap_log_error() has undergone significant changes in Apache 2.4. + // Validate Apache version for using a proper ap_log_error() version. + #if AP_SERVER_MAJORVERSION_NUMBER == 2 && AP_SERVER_MINORVERSION_NUMBER < 4 + ap_log_error(file, line, level, 0, NULL, "%s", text); + #else + ap_log_error(file, line, level, 0, NULL, 0, text); + #endif } @@ -170,14 +176,25 @@ extern "C" int ApacheConnector_handler(request_rec *r) apr_status_t rv; if ((rv = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK))) - return rv; - - std::unique_ptr pRequest(new ApacheServerRequest( - &rec, - r->connection->local_ip, - r->connection->local_addr->port, - r->connection->client_ip, - r->connection->client_addr->port)); + return rv; + + // The properties conn_rec->remote_ip and conn_rec->remote_addr have undergone significant changes in Apache 2.4. + // Validate Apache version for using conn_rec->remote_ip and conn_rec->remote_addr proper versions. + #if AP_SERVER_MAJORVERSION_NUMBER == 2 && AP_SERVER_MINORVERSION_NUMBER < 4 + std::unique_ptr pRequest(new ApacheServerRequest( + &rec, + r->connection->local_ip, + r->connection->local_addr->port, + r->connection->remote_ip, + r->connection->remote_addr->port)); + #else + std::unique_ptr pRequest(new ApacheServerRequest( + &rec, + r->connection->local_ip, + r->connection->local_addr->port, + r->connection->client_ip, + r->connection->client_addr->port)); + #endif std::unique_ptr pResponse(new ApacheServerResponse(pRequest.get())); From 87556aa2d3c2595b2a308a7c82ddb364409d3919 Mon Sep 17 00:00:00 2001 From: Aleksandar Fabijanic Date: Tue, 17 Oct 2017 12:30:58 -0500 Subject: [PATCH 3/3] Update ApacheConnector.cpp --- ApacheConnector/src/ApacheConnector.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ApacheConnector/src/ApacheConnector.cpp b/ApacheConnector/src/ApacheConnector.cpp index f93caaab27..6a1503d8c0 100644 --- a/ApacheConnector/src/ApacheConnector.cpp +++ b/ApacheConnector/src/ApacheConnector.cpp @@ -151,11 +151,11 @@ void ApacheConnector::log(const char* file, int line, int level, int status, con { // ap_log_error() has undergone significant changes in Apache 2.4. // Validate Apache version for using a proper ap_log_error() version. - #if AP_SERVER_MAJORVERSION_NUMBER == 2 && AP_SERVER_MINORVERSION_NUMBER < 4 +#if AP_SERVER_MAJORVERSION_NUMBER == 2 && AP_SERVER_MINORVERSION_NUMBER < 4 ap_log_error(file, line, level, 0, NULL, "%s", text); - #else +#else ap_log_error(file, line, level, 0, NULL, 0, text); - #endif +#endif } @@ -180,21 +180,21 @@ extern "C" int ApacheConnector_handler(request_rec *r) // The properties conn_rec->remote_ip and conn_rec->remote_addr have undergone significant changes in Apache 2.4. // Validate Apache version for using conn_rec->remote_ip and conn_rec->remote_addr proper versions. - #if AP_SERVER_MAJORVERSION_NUMBER == 2 && AP_SERVER_MINORVERSION_NUMBER < 4 +#if AP_SERVER_MAJORVERSION_NUMBER == 2 && AP_SERVER_MINORVERSION_NUMBER < 4 std::unique_ptr pRequest(new ApacheServerRequest( &rec, r->connection->local_ip, r->connection->local_addr->port, r->connection->remote_ip, r->connection->remote_addr->port)); - #else +#else std::unique_ptr pRequest(new ApacheServerRequest( &rec, r->connection->local_ip, r->connection->local_addr->port, r->connection->client_ip, r->connection->client_addr->port)); - #endif +#endif std::unique_ptr pResponse(new ApacheServerResponse(pRequest.get()));