]> granicus.if.org Git - apache/commitdiff
Save some cycle.
authorChristophe Jaillet <jailletc36@apache.org>
Sat, 18 Aug 2018 08:32:15 +0000 (08:32 +0000)
committerChristophe Jaillet <jailletc36@apache.org>
Sat, 18 Aug 2018 08:32:15 +0000 (08:32 +0000)
There is no need to copy, strchr, strcmp and modify a string which is only used for TRACE2 logging.

Note that the code that looks similar a few lines below can not be optimized the same way because it is also returned in 'pmessage'.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1838318 13f79535-47bb-0310-9956-ffa450edef68

modules/proxy/mod_proxy_ftp.c

index d979e9f9c448e6b122f049bdf4ecb889eb8b0cb8..d763572ccb81b84a0e5fc95ac91b8330e1b97304 100644 (file)
@@ -813,17 +813,19 @@ proxy_ftp_command(const char *cmd, request_rec *r, conn_rec *ftp_ctrl,
         APR_BRIGADE_INSERT_TAIL(bb, apr_bucket_flush_create(c->bucket_alloc));
         ap_pass_brigade(ftp_ctrl->output_filters, bb);
 
-        /* strip off the CRLF for logging */
-        apr_cpystrn(message, cmd, sizeof(message));
-        if ((crlf = strchr(message, '\r')) != NULL ||
-            (crlf = strchr(message, '\n')) != NULL)
-            *crlf = '\0';
-        if (strncmp(message,"PASS ", 5) == 0)
-            strcpy(&message[5], "****");
-        ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r, ">%s", message);
+        if (APLOGrtrace2(r)) {
+            /* strip off the CRLF for logging */
+            apr_cpystrn(message, cmd, sizeof(message));
+            if ((crlf = strchr(message, '\r')) != NULL ||
+                (crlf = strchr(message, '\n')) != NULL)
+                *crlf = '\0';
+            if (strncmp(message,"PASS ", 5) == 0)
+                strcpy(&message[5], "****");
+            ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r, ">%s", message);
+        }
     }
 
-    rc = ftp_getrc_msg(ftp_ctrl, bb, message, sizeof message);
+    rc = ftp_getrc_msg(ftp_ctrl, bb, message, sizeof(message));
     if (rc == -1 || rc == 421)
         strcpy(message,"<unable to read result>");
     if ((crlf = strchr(message, '\r')) != NULL ||