[JDEV] [patch client.c]

Rodolphe Duge de Bernonville rod at idealx.com
Mon Mar 5 07:53:26 CST 2001


Under heavy load (high connection/disconnection), 
User authentification may take a few seconds, 
if the user is disconnected while he is waiting for
the creation of his session, he will be removed
from the hashlist of the clients but as his state is 
not state_AUTHD, he will receive the ack of session
creation but his session will never receive a typed-error
route.

After that, pthsock_client will try to write the ack 
for authentification, so before writin, you must
verify that the user is still here (because mio struct has
been freed .. ooops :).




@@ -97,13 +97,25 @@
     if(p->id->user != NULL)
         fd = atoi(p->id->user); 
     
-    if(p->type != p_ROUTE || fd == 0 || (cdcur = ghash_get(s__i->users,
xmlnode_get_attrib(p->x, "to"))) == NULL)
+    if(p->type != p_ROUTE || fd == 0)
     { /* we only want <route/> packets or ones with a valid connection
*/
         log_warn(p->host, "pthsock_client bouncing invalid %s packet
from %s", xmlnode_get_name(p->x), xmlnode_get_attrib(p->x,"from"));
         deliver_fail(p, "invalid client packet");
         return r_DONE;
     }
 
+
+    if ((cdcur = ghash_get(s__i->users, xmlnode_get_attrib(p->x,
"to"))) == NULL){
+	if (!j_strcmp(xmlnode_get_attrib(p->x, "type"),  "session")){
+		jutil_tofrom(p->x);
+		xmlnode_put_attrib(p->x, "type", "error");
+		deliver(dpacket_new(p->x), s__i->i);
+        } 
+	else
+	    xmlnode_free(p->x);
+        return r_DONE;
+    }
+
     if (fd != cdcur->m->fd || cdcur->m->state != state_ACTIVE)
         m = NULL;
     else if (j_strcmp(p->id->resource,cdcur->res) != 0)
@@ -177,7 +189,7 @@
     }
 
 
-    if(xmlnode_get_firstchild(p->x) == NULL)
+    if(xmlnode_get_firstchild(p->x) == NULL ||  ghash_get(s__i->users,
xmlnode_get_attrib(p->x, "to")) == NULL)
     {
         xmlnode_free(p->x);
     }




More information about the JDev mailing list