httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfcl...@apache.org
Subject svn commit: r426717 - /httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/health_checker_util.c
Date Sat, 29 Jul 2006 00:20:21 GMT
Author: jfclere
Date: Fri Jul 28 17:20:21 2006
New Revision: 426717

URL: http://svn.apache.org/viewvc?rev=426717&view=rev
Log:
Arrange stuff reported by Davi Arnaud. (thanks).

Modified:
    httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/health_checker_util.c

Modified: httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/health_checker_util.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/health_checker_util.c?rev=426717&r1=426716&r2=426717&view=diff
==============================================================================
--- httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/health_checker_util.c (original)
+++ httpd/httpd/branches/httpd-proxy-scoreboard/modules/proxy/health_checker_util.c Fri Jul
28 17:20:21 2006
@@ -34,7 +34,7 @@
 #include "ajp.h"
 
 static const slotmem_storage_method *checkstorage = NULL;
-static ap_slotmem_t *myscore=NULL;
+static ap_slotmem_t *myscore = NULL;
 
 /* Check a AJP back-end server.
  * Send a cing message and wait for the answer
@@ -71,23 +71,18 @@
     apr_sockaddr_t *epsv_addr;
     apr_status_t rv;
 
-    if (!port) {
-        if (strcmp(scheme, "ajp") == 0)
-            port = 8009;
-        else if (strcmp(scheme, "http") == 0)
-            port = 80;
-        else
-            port = 443;
-    }
+    /* Note that AJP requires a new apr-util (29-07-2006) */
+    if (!port)
+        port  = (int) apr_uri_port_of_scheme(scheme);
     rv = apr_socket_create(&newsock, APR_INET, SOCK_STREAM, APR_PROTO_TCP, pool);
     if (rv != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL,
                     "apr_socket_create failed");
         return rv;
     }
     rv = apr_sockaddr_info_get(&epsv_addr, hostname, APR_INET, port, 0, pool);
     if (rv != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
+        ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL,
                      "apr_sockaddr_info_get failed");
         apr_socket_close(newsock);
         return rv;
@@ -95,26 +90,26 @@
 
     rv = apr_socket_timeout_set(newsock, 10);
     if (rv != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL,
+        ap_log_error(APLOG_MARK, APLOG_WARNING, rv, NULL,
                     "apr_socket_timeout_set");
         apr_socket_close(newsock);
         return rv;
     }
     rv = apr_socket_connect(newsock, epsv_addr);
     if (rv != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,
+        ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, NULL,
                     "apr_socket_connect failed");
         apr_socket_close(newsock);
         return rv;
     }
 
     /* XXX: Something is needed for http/https */
-    if (strcmp(scheme, "ajp") == 0) {
+    if (strcasecmp(scheme, "ajp") == 0) {
         /* The connection is etablished send a ping and read the answer */
         apr_socket_timeout_set(newsock, 10000);
         rv = pingc_backend(newsock, pool);  
         if (rv != APR_SUCCESS) {
-            ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, NULL,
+            ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, NULL,
                         "pingc_backend failed");
             apr_socket_close(newsock);
             return rv;
@@ -143,20 +138,20 @@
     }
 
     if (balancer_name)
-        strcpy(workerconf->balancer_name, balancer_name);
+        strncpy(workerconf->balancer_name, balancer_name, sizeof(workerconf->balancer_name));
     workerconf->id = worker->id;
     workerconf->retry = worker->retry;
     workerconf->lbfactor = worker->lbfactor;
     if (worker->name)
-        strcpy(workerconf->name, worker->name);
+        strncpy(workerconf->name, worker->name, sizeof(workerconf->name));
     if (worker->scheme)
-        strcpy(workerconf->scheme, worker->scheme);
+        strncpy(workerconf->scheme, worker->scheme, sizeof(workerconf->scheme));
     if (worker->hostname)
-        strcpy(workerconf->hostname, worker->hostname);
+        strncpy(workerconf->hostname, worker->hostname, sizeof(workerconf->hostname));
     if (worker->route)
-        strcpy(workerconf->route, worker->route);
+        strncpy(workerconf->route, worker->route, sizeof(workerconf->route));
     if (worker->redirect)
-        strcpy(workerconf->redirect, worker->redirect);
+        strncpy(workerconf->redirect, worker->redirect, sizeof(workerconf->redirect));
     workerconf->status = worker->status;
     workerconf->port = worker->port;
     workerconf->min = worker->min;
@@ -227,8 +222,10 @@
 
     /* allocate the data */
     *worker = apr_pcalloc(pool, sizeof(proxy_worker));
-    if (workerconf->balancer_name)
+    if (workerconf->balancer_name) {
         *balancer_name = apr_pcalloc(pool, strlen(workerconf->balancer_name) + 1);
+        strcpy(*balancer_name, workerconf->balancer_name);
+    }
     else
         *balancer_name = NULL;
 



Mime
View raw message