Author: mturk
Date: Sat May  5 10:49:41 2012
New Revision: 1334392

URL: http://svn.apache.org/viewvc?rev=1334392&view=rev
Log:
Make sure address is correctly resolved

Modified:
    tomcat/jk/trunk/native/common/jk_ajp_common.c
    tomcat/jk/trunk/native/common/jk_shm.c

Modified: tomcat/jk/trunk/native/common/jk_ajp_common.c
URL: 
http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_ajp_common.c?rev=1334392&r1=1334391&r2=1334392&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_ajp_common.c (original)
+++ tomcat/jk/trunk/native/common/jk_ajp_common.c Sat May  5 10:49:41 2012
@@ -1065,11 +1065,15 @@ void jk_ajp_pull(ajp_worker_t * aw, int 
         jk_shm_unlock();
 
     if (address_change == JK_TRUE && port != 0) {
+        aw->port = port;
+        strncpy(aw->host, host, JK_SHM_STR_SIZ);
         if (!jk_resolve(host, port, &inet_addr,
                         aw->worker.we->pool, l)) {
             jk_log(l, JK_LOG_ERROR,
                    "Failed resolving address '%s:%d' for worker '%s'.",
                    host, port, aw->name);
+            /* Disable contact */
+            aw->port = 0;
         }
         else {
             unsigned int i;
@@ -1086,8 +1090,6 @@ void jk_ajp_pull(ajp_worker_t * aw, int 
                     aw->s->connected--;
                 }
             }
-            aw->port = port;
-            strncpy(aw->host, host, JK_SHM_STR_SIZ);
             memcpy(&(aw->worker_inet_addr), &inet_addr, sizeof(inet_addr));
             JK_LEAVE_CS(&aw->cs);
         }
@@ -2684,9 +2686,8 @@ int ajp_validate(jk_worker_t *pThis,
                    p->name, p->host, p->port);
         /* Copy the contact to shm
          */
-        if (p->sequence == 0) {
+        if (p->s->h.sequence == 0) {
             /* Initial setup.
-             * Invalidate addr_sequence so that the address in resolved.
              */
             if (p->port > 0) {
                 if (!jk_resolve(p->host, p->port, &p->worker_inet_addr, 
we->pool, l)) {
@@ -2699,15 +2700,8 @@ int ajp_validate(jk_worker_t *pThis,
                                "worker %s contact is disabled",
                                p->name);
                 }
-                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->addr_sequence = p->s->addr_sequence;
+            p->s->addr_sequence = 1;
             p->s->last_maintain_time = time(NULL);
             p->s->last_reset = p->s->last_maintain_time;
             jk_ajp_push(p, JK_TRUE, l);
@@ -2719,8 +2713,8 @@ int ajp_validate(jk_worker_t *pThis,
                 jk_log(l, JK_LOG_DEBUG,
                        "worker %s contact already configured (%u->%u",
                         p->name, p->s->addr_sequence, p->addr_sequence);
-            jk_ajp_pull(p, JK_TRUE, l);        
-        }            
+            jk_ajp_pull(p, JK_TRUE, l);
+        }
         JK_TRACE_EXIT(l);
         return JK_TRUE;
     }

Modified: tomcat/jk/trunk/native/common/jk_shm.c
URL: 
http://svn.apache.org/viewvc/tomcat/jk/trunk/native/common/jk_shm.c?rev=1334392&r1=1334391&r2=1334392&view=diff
==============================================================================
--- tomcat/jk/trunk/native/common/jk_shm.c (original)
+++ tomcat/jk/trunk/native/common/jk_shm.c Sat May  5 10:49:41 2012
@@ -295,6 +295,7 @@ int jk_shm_open(const char *fname, int s
          * if the number of workers change between
          * open and attach or between two attach operations.
          */
+#if 0
         if (jk_shmem.hdr->h.data.childs > 1) {
             if (JK_IS_DEBUG_LEVEL(l)) {
                 jk_log(l, JK_LOG_DEBUG,
@@ -302,7 +303,6 @@ int jk_shm_open(const char *fname, int s
                        jk_shmem.hdr->h.data.childs);
             }
         }
-#if 0
         jk_shmem.hdr->h.data.pos     = 0;
         jk_shmem.hdr->h.data.workers = 0;
 #endif
@@ -316,9 +316,11 @@ int jk_shm_open(const char *fname, int s
     JK_LEAVE_CS(&jk_shmem.cs);
     if (JK_IS_DEBUG_LEVEL(l))
         jk_log(l, JK_LOG_DEBUG,
-               "%s shared memory %s size=%u workers=%d free=%u addr=%#lx",
+               "%s shared memory %s [%d] size=%u workers=%d free=%u addr=%#lx",
                attached ? "Attached" : "Initialized",
-               jk_shm_name(), jk_shmem.size, jk_shmem.hdr->h.data.workers,
+               jk_shm_name(),
+               jk_shmem.hdr->h.data.childs,
+               jk_shmem.size, jk_shmem.hdr->h.data.workers - 1,
                jk_shmem.hdr->h.data.size - jk_shmem.hdr->h.data.pos,
                jk_shmem.hdr);
     JK_TRACE_EXIT(l);
@@ -626,16 +628,17 @@ static int do_shm_open(const char *fname
                    jk_shmem.hdr);
     }
     else {
-        unsigned int nchild;
         jk_shmem.hdr->h.data.childs++;
         jk_shmem.attached = (int)getpid();
-        nchild = jk_shmem.hdr->h.data.childs;
         if (JK_IS_DEBUG_LEVEL(l))
             jk_log(l, JK_LOG_DEBUG,
-                   "Attached shared memory %s [%d] size=%u free=%u addr=%#lx",
-                   jk_shm_name(), nchild, jk_shmem.size,
+                   "Attached shared memory %s [%d] size=%u workers=%u free=%u 
addr=%#lx",
+                   jk_shm_name(),
+                   jk_shmem.hdr->h.data.childs,
+                   jk_shmem.size, jk_shmem.hdr->h.data.workers - 1,
                    jk_shmem.hdr->h.data.size - jk_shmem.hdr->h.data.pos,
                    jk_shmem.hdr);
+#if 0
         /*
          * Reset the shared memory so that
          * alloc works even for attached memory.
@@ -652,6 +655,7 @@ static int do_shm_open(const char *fname
         }
         jk_shmem.hdr->h.data.pos     = 0;
         jk_shmem.hdr->h.data.workers = 0;
+#endif
     }
     if ((rc = do_shm_open_lock(jk_shmem.filename, attached, l))) {
         if (!attached) {



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

Reply via email to