Hi,
the attached patch fixes two things in the HSEP implementation:
- The "Sending x triples ..." message should now show the correct
triples to be sent (before this, it would not show the correct
triples, but would repeat a possibly wrong triple). The sending
itself was done correctly, though.
- Changes in shared files/KiB are recognized immediately (before this,
they were recognized only when "Rescan" was clicked). So now, also
changing the number of upload slots from 0 to something else or vice
versa directly shows effect. The check is skipped if the shared files
are being scanned.
- The sanity check has been simplified.
Please commit this to CVS, unless you have any objections.
Thanks!
Greetings,
Thomas.
Index: hsep.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/hsep.c,v
retrieving revision 1.6
diff -u -r1.6 hsep.c
--- hsep.c 2 Mar 2004 14:03:19 -0000 1.6
+++ hsep.c 2 Mar 2004 15:09:38 -0000
@@ -200,6 +200,18 @@
{
time_t now = time(NULL);
GSList *sl;
+ gboolean scanning_shared;
+
+ /* update number of shared files and KiB */
+
+ gnet_prop_get_boolean_val(PROP_LIBRARY_REBUILDING, &scanning_shared);
+
+ if (!scanning_shared) {
+ if (upload_is_enabled())
+ hsep_notify_shared(files_scanned, kbytes_scanned);
+ else
+ hsep_notify_shared(0, 0);
+ }
for (sl = (GSList *) node_all_nodes(); sl; sl = g_slist_next(sl)) {
struct gnutella_node *n = (struct gnutella_node *) sl->data;
@@ -449,6 +461,9 @@
opttriples = hsep_triples_to_send(
(hsep_triple *) ((&m->header) + 1), triples);
+ globalt = (guint64 *) &hsep_global_table[1];
+ connectiont = (guint64 *) &n->hsep_table[1];
+
printf("HSEP: Sending %d %s to node %p (msg #%u): ", opttriples,
opttriples == 1 ? "triple" : "triples", n, n->hsep_msgs_sent + 1);
@@ -456,6 +471,8 @@
printf("(%llu,%llu,%llu) ", ownt[0] + globalt[0] - connectiont[0],
ownt[1] + globalt[1] - connectiont[1],
ownt[2] + globalt[2] - connectiont[2]);
+ globalt += 3;
+ connectiont += 3;
}
printf("\n");
@@ -547,9 +564,6 @@
memset(sum, 0, sizeof(sum));
g_assert(hsep_own[HSEP_IDX_NODES] == 1);
- g_assert(hsep_global_table[0][HSEP_IDX_NODES] == 0);
- g_assert(hsep_global_table[0][HSEP_IDX_FILES] == 0);
- g_assert(hsep_global_table[0][HSEP_IDX_KIB] == 0);
/*
* Iterate over all HSEP-capable nodes, and for each triple position
@@ -578,26 +592,21 @@
hsep_check_monotony((hsep_triple *) (connectiont + 3),
HSEP_N_MAX)
);
- /*
- * Sum up the values (skip first triple, already checked for zero)
- */
-
- connectiont += 3;
- sumt += 3;
+ /* sum up the values */
- for (i = 0; i < HSEP_N_MAX; i++) {
+ for (i = 0; i <= HSEP_N_MAX; i++) {
*sumt++ += *connectiont++;
*sumt++ += *connectiont++;
*sumt++ += *connectiont++;
}
}
- globalt = (guint64 *) &hsep_global_table[1];
- sumt = (guint64 *) &sum[1];
+ globalt = (guint64 *) hsep_global_table;
+ sumt = (guint64 *) sum;
- /* we needn't check for i=0 (we've done that already) */
+ /* check sums */
- for (i = 0; i < HSEP_N_MAX; i++) {
+ for (i = 0; i <= HSEP_N_MAX; i++) {
g_assert(*globalt == *sumt);
globalt++;
sumt++;
@@ -608,12 +617,6 @@
globalt++;
sumt++;
}
-
- /*
- * As each connection's triples are in monotonously
- * increasing order, the same is automatically true for
- * the global table
- */
}
/*
Index: share.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/share.c,v
retrieving revision 1.133
diff -u -r1.133 share.c
--- share.c 29 Feb 2004 19:36:56 -0000 1.133
+++ share.c 2 Mar 2004 15:09:43 -0000
@@ -1148,22 +1148,6 @@
in_share_scan = FALSE;
gnet_prop_set_boolean_val(PROP_LIBRARY_REBUILDING, FALSE);
-
- /*
- * Tell HSEP about our shared resources.
- *
- * Note that currently HSEP only (re-)learns about resources when
- * files are scanned, not when the number of upload slots is
- * changed from 0 or to 0 in the GUI. We'd have to listen for
- * that event and would have to call the same code as specified
- * below. As shared files are scanned every 1000 seconds, this should
- * be ok.
- */
-
- if (max_uploads > 0)
- hsep_notify_shared(files_scanned, kbytes_scanned);
- else
- hsep_notify_shared(0, 0);
}
void share_close(void)