On 19.02.2009 13:55, mt...@apache.org wrote:
Author: mturk
Date: Thu Feb 19 12:55:05 2009
New Revision: 745842

URL: http://svn.apache.org/viewvc?rev=745842&view=rev
Log:
Allow dynamic worker address change

Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c?rev=745842&r1=745841&r2=745842&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Thu Feb 19 
12:55:05 2009
@@ -2167,6 +2167,18 @@
      jk_shm_lock();
      if (aw->sequence != aw->s->h.sequence)
          jk_ajp_pull(aw, l);
+    if (aw->addr_sequence != aw->s->addr_sequence) {
+        aw->addr_sequence = aw->s->addr_sequence;
+        aw->host = aw->s->hostname;

Should we copy the string here?

+        aw->port = aw->s->port;
+        if (!jk_resolve(aw->host, aw->port,&aw->worker_inet_addr,
+                        aw->worker.we->pool, l)) {
+            if (is_error)
+                *is_error = JK_HTTP_SERVER_ERROR;

i think we should log an error in this case and maybe also reset the data to the previous working set.

+            JK_TRACE_EXIT(l);
+            return JK_FALSE;
+       }
+    }
      jk_shm_unlock();

      aw->s->used++;
@@ -2464,24 +2476,39 @@
          ajp_worker_t *p = pThis->worker_private;
          p->port = jk_get_worker_port(props, p->name, port);
          p->host = jk_get_worker_host(props, p->name, host);
+        if (!p->host) {
+            p->host = "undefined";
+        }

Guess we don't need that, because jk_get_worker_host() already gets a default as the last argument (usually localhost).

          if (JK_IS_DEBUG_LEVEL(l))
              jk_log(l, JK_LOG_DEBUG,
                     "worker %s contact is '%s:%d'",
                     p->name, p->host, p->port);
-
-/* XXX: Why do we only resolve, if port>  1024 ? */
+        /* Copy the contact to shm */
+        strncpy(p->s->hostname, p->host, JK_SHM_STR_SIZ);
+        p->s->port = p->port;
+        /* Resolve if port>  1024.
+         *
+         */
          if (p->port>  1024) {
              if (jk_resolve(p->host, p->port,&p->worker_inet_addr, we->pool, 
l)) {
+                p->s->addr_sequence = p->addr_sequence = 1;
                  JK_TRACE_EXIT(l);
                  return JK_TRUE;
              }
              jk_log(l, JK_LOG_ERROR,
-                   "can't resolve tomcat address %s", p->host);
+                   "worker %s can't resolve tomcat address %s",
+                   p->name, p->host);
+        }
+        else {
+            p->s->port = p->port = 0;
+            if (JK_IS_DEBUG_LEVEL(l))
+                jk_log(l, JK_LOG_DEBUG,
+                       "worker %s contact is disabled",
+                       p->name, p->host, p->port);
+            JK_TRACE_EXIT(l);
+            return JK_TRUE;
          }
-        jk_log(l, JK_LOG_ERROR,
-               "invalid host and port %s %d",
-               ((p->host == NULL) ? "NULL" : p->host), p->port);

It was an error log message, now it is debug. Why don't we simpy allow ports below 1024?

Regards,

Rainer

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to