Permalink
Browse files

Added some search dispatching debugging / sanity checking.

  • Loading branch information...
1 parent 199fb4f commit f58cc3f9007d7eaeb84a1ed8e6d68e19507bf9c1 @rmanfredi rmanfredi committed May 2, 2012
Showing with 65 additions and 9 deletions.
  1. +41 −2 src/core/search.c
  2. +24 −7 src/ui/gtk/search_common.c
View
43 src/core/search.c
@@ -2141,8 +2141,8 @@ get_results_set(gnutella_node_t *n, bool browse)
/* We shall try to detect malformed packets as best as we can */
if (n->size < 27) {
/* packet too small 11 header, 16 GUID min */
- g_warning("get_results_set(): given too small a packet (%d bytes)",
- n->size);
+ g_warning("%s(): given too small a packet (%d bytes)",
+ G_STRFUNC, n->size);
gnet_stats_count_dropped(n, MSG_DROP_TOO_SMALL);
return NULL;
}
@@ -4726,10 +4726,49 @@ search_results(gnutella_node_t *n, int *results)
const guid_t *muid = gnutella_header_get_muid(&n->header);
const guid_t *guess_muid = NULL;
+ /*
+ * When dealing with a GUESS search we have to pass in the GUESS
+ * query MUID so that this parameter may be passed back by the GUI
+ * once it has filtered results and we know we're being notified
+ * about kept results for a GUESS search (and which one), which in
+ * turn allows us to track the amount of meaningful results that a
+ * GUESS query generates.
+ *
+ * So this GUESS MUID we're giving to the GUID is to be construed
+ * as an opaque ID that allows us to tie our ends in the core side.
+ *
+ * This complication is only necessary because results filtering
+ * happens in the GUI and not in the core as it should (FIXME, but
+ * this is far from trivial as the whole filtering configuration
+ * must be exchanged between the core and the GUI, along with the
+ * associated statistics, for proper GUI display and editing).
+ */
+
if (guess_is_search_muid(muid)) {
rs->status |= ST_GUESS;
guess_got_results(muid, rs->num_recs);
guess_muid = muid;
+
+ if (GNET_PROPERTY(guess_client_debug) > 5) {
+ search_ctrl_t *sch;
+ sch = htable_lookup(search_by_muid, muid);
+ if (NULL == sch) {
+ g_carp("%s(): GUESS search %s not found by MUID",
+ G_STRFUNC, guid_to_string(muid));
+ } else {
+ void *data = g_slist_find(selected_searches,
+ uint_to_pointer(sch->search_handle));
+ if (NULL == data) {
+ g_carp("%s(): GUESS search %s not selected!",
+ G_STRFUNC, guid_to_string(muid));
+ } else {
+ g_debug("GUESS delivering hit with %u record%s "
+ "for \"%s\" %s",
+ rs->num_recs, 1 == rs->num_recs ? "" : "s",
+ sch->name, guid_to_string(muid));
+ }
+ }
+ }
}
search_results_set_flag_records(rs);
View
31 src/ui/gtk/search_common.c
@@ -1967,11 +1967,15 @@ search_matched(search_t *sch, const guid_t *muid, results_set_t *rs)
}
if (GUI_PROPERTY(gui_debug) > 6) {
- g_debug("%s(): [%s] got hit with %d record%s (from %s) "
+ g_debug("%s(): [%s] got hit with %d record%s (from %s via %s%s%s%s) "
"need_push=%d, skipping=%d", G_STRFUNC,
search_gui_query(sch), rs->num_recs, rs->num_recs == 1 ? "" : "s",
host_addr_port_to_string(rs->addr, rs->port),
- (flags & SOCK_F_PUSH), skip_records);
+ (rs->status & ST_UDP) ? "UDP" : "TCP",
+ (rs->status & ST_GUESS) ? " + GUESS" : "",
+ (NULL == muid) ? "" : " ",
+ (NULL == muid) ? "" : guid_to_string(muid),
+ booleanize(flags & SOCK_F_PUSH), skip_records);
}
for (sl = rs->records; sl && !skip_records; sl = g_slist_next(sl)) {
@@ -2310,13 +2314,21 @@ search_gui_got_results(GSList *schl, const struct guid *muid,
if (rs) {
struct accum_rs *ars;
- if (GUI_PROPERTY(gui_debug) >= 12)
+ if (GUI_PROPERTY(gui_debug) >= 12) {
g_debug("%s(): got incoming results...", G_STRFUNC);
+ }
WALLOC(ars);
ars->muid = muid != NULL ? atom_guid_get(muid) : NULL;
ars->rs = rs;
slist_append(accumulated_rs, ars);
+ } else {
+ if (GUI_PROPERTY(gui_debug) >= 6) {
+ g_debug("%s(): ignoring %u result%s%s%s",
+ G_STRFUNC, r_set->num_recs, 1 == r_set->num_recs ? "" : "s",
+ NULL == muid ? "" : " for GUESS ",
+ NULL == muid ? "" : guid_to_string(muid));
+ }
}
}
@@ -2365,9 +2377,8 @@ search_gui_flush(time_t now, gboolean force)
tm_t t0, t1;
if (!force) {
- guint32 period;
+ guint32 period = GUI_PROPERTY(search_accumulation_period);
- gui_prop_get_guint32_val(PROP_SEARCH_ACCUMULATION_PERIOD, &period);
if (last && delta_time(now, last) < (time_delta_t) period)
return;
}
@@ -2390,6 +2401,12 @@ search_gui_flush(time_t now, gboolean force)
schl = rs->schl;
rs->schl = NULL;
+ if (GUI_PROPERTY(gui_debug) > 6 && muid != NULL) {
+ g_debug("%s(): processing accumulated %u record%s for %s",
+ G_STRFUNC, rs->num_recs, 1 == rs->num_recs ? "" : "s",
+ guid_to_string(muid));
+ }
+
search_gui_set_record_info(rs);
/*
@@ -2417,8 +2434,8 @@ search_gui_flush(time_t now, gboolean force)
}
search_matched(sch, muid, rs);
} else if (GUI_PROPERTY(gui_debug) >= 6) {
- g_debug(
- "no search for cached search result while dispatching");
+ g_debug("%s(): no search for cached search result (handle #%u)",
+ G_STRFUNC, handle);
}
}
gm_slist_free_null(&schl);

0 comments on commit f58cc3f

Please sign in to comment.