> Quoting Thomas Schuerger <[EMAIL PROTECTED]> from ml.softs.gtk-gnutella.devel:
> :As this is a serious problem, it should be applied to CVS ASAP.
> 
> To help with "ASAP" integration, could you rewrite your patch to have
> the brace on the same line as "if" and "while" keywords:
> 
>     if (cond) {     /* comment */
>         ...
>     }

Sure, sorry about that. We need a script the checks code style. ;-)

New patch is attached.


Greetings,
Thomas.
Index: hsep.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/hsep.c,v
retrieving revision 1.9
diff -u -r1.9 hsep.c
--- hsep.c      3 Mar 2004 18:38:44 -0000       1.9
+++ hsep.c      9 Mar 2004 14:53:49 -0000
@@ -157,8 +157,7 @@
 /*
  * hsep_connection_init
  *
- * Initializes the connection's HSEP data to zero and sends the first HSEP
- * message to the node. Node must support HSEP.
+ * Initializes the connection's HSEP data.
  */
  
 void hsep_connection_init(struct gnutella_node *n)
@@ -185,8 +184,6 @@
        n->hsep_msgs_sent = 0;
        n->hsep_triples_sent = 0;
        n->hsep_last_sent = 0;
-
-       hsep_send_msg(n);
 }
 
 /*
@@ -294,15 +291,25 @@
        messaget = (guint64 *) n->data;
        connectiont = (guint64 *) &n->hsep_table[1];
        
-       if (length == 0)  /* error, at least 1 triple must be present */
+       if (length == 0) {   /* error, at least 1 triple must be present */
+               printf("HSEP: Node %p sent empty message\n", n);
                return;
+       }
 
-       if (length % 24)  /* error, # of triples not an integer */
+       if (length % 24) {   /* error, # of triples not an integer */
+               printf("HSEP: Node %p sent broken message\n", n);
                return;
+       }
 
        /* get N_MAX of peer servent (other_n_max) */
        msgmax = length / 24;
 
+       if (NODE_IS_LEAF(n) && msgmax > 1) {
+               printf("HSEP: Node %p is a leaf, but sent %u triples instead of 1\n",
+                       n, msgmax);
+               return;
+       }
+
        /* truncate if peer servent sent more triples than we need */
        if (msgmax > HSEP_N_MAX)
                max = HSEP_N_MAX;
@@ -328,11 +335,15 @@
 
        /* sanity check */
 
-       if (*messaget != 1)  /* number of nodes for 1 hop must be 1 */
+       if (*messaget != 1) {   /* number of nodes for 1 hop must be 1 */
+               printf("HSEP: Node %p's message's #nodes for 1 hop is not 1", n);
                return;
+       }
 
-       if (!hsep_check_monotony((hsep_triple *) messaget, max))
+       if (!hsep_check_monotony((hsep_triple *) messaget, max)) {
+               printf("HSEP: Node %p's message's monotony check failed", n);
                return;
+       }
 
        printf("HSEP: Received %d %s from node %p (msg #%u): ", max,
            max == 1 ? "triple" : "triples", n, n->hsep_msgs_received + 1);
Index: nodes.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/nodes.c,v
retrieving revision 1.322
diff -u -r1.322 nodes.c
--- nodes.c     25 Feb 2004 20:15:23 -0000      1.322
+++ nodes.c     9 Mar 2004 14:53:52 -0000
@@ -2460,11 +2460,6 @@
                }
        }
 
-       /* Initialize connection's HSEP data and send first HSEP message. */
-
-       if (n->attrs & NODE_A_CAN_HSEP)
-               hsep_connection_init(n);
-
        /*
         * If we're an Ultranode, we're going to monitor the queries sent by
         * our leaves and by our neighbours.
@@ -3737,8 +3732,11 @@
                
                header_get_feature("hsep", head, &major, &minor);
  
-               if (major == HSEP_VERSION_MAJOR && minor == HSEP_VERSION_MINOR)
+               if (major == HSEP_VERSION_MAJOR && minor == HSEP_VERSION_MINOR) {
                        n->attrs |= NODE_A_CAN_HSEP;
+                       hsep_connection_init(n);
+                       /* first HSEP message will be sent on next hsep_timer() call */
+               }
        }
        
        /*

Reply via email to