static bool free_node_id(const void *key, void *unused_udata) { (void) unused_udata; nid_unref(key); return TRUE; }
/** * Removes all references to the given node handle in the gui. */ void nodes_gui_remove_node(const struct nid *node_id) { GtkWidget *clist_nodes; gint row; clist_nodes = gui_main_window_lookup("clist_nodes"); /* * Make sure node is remove from the "changed" hash table so * we don't try an update. */ g_assert(NULL != hs_node_info_changed); g_assert(NULL != hs_node_flags_changed); remove_item(hs_node_info_changed, node_id); remove_item(hs_node_flags_changed, node_id); row = gtk_clist_find_row_from_data(GTK_CLIST(clist_nodes), deconstify_gpointer(node_id)); if (row != -1) { gtk_clist_remove(GTK_CLIST(clist_nodes), row); nid_unref(node_id); } else { g_warning("%s(): no matching row found", G_STRFUNC); } }
static void host_lookup_callback(const gchar *hostname, gpointer key) { const struct nid *node_id = key; gnet_node_info_t info; struct node_data *data; host_addr_t addr; guint16 port; if (!ht_pending_lookups) goto finish; if (!remove_item(ht_pending_lookups, node_id)) goto finish; data = find_node(node_id); if (!data) goto finish; guc_node_fill_info(node_id, &info); g_assert(node_id == info.node_id); addr = info.addr; port = info.port; guc_node_clear_info(&info); WFREE_NULL(data->host, data->host_size); if (hostname) { const gchar *host; gchar *to_free; if (utf8_is_valid_string(hostname)) { to_free = NULL; host = hostname; } else { to_free = locale_to_utf8_normalized(hostname, UNI_NORM_GUI); host = to_free; } data->host_size = w_concat_strings(&data->host, host, " (", host_addr_port_to_string(addr, port), ")", (void *) 0); G_FREE_NULL(to_free); } else { statusbar_gui_warning(10, _("Reverse lookup for %s failed"), host_addr_to_string(addr)); data->host_size = w_concat_strings(&data->host, host_addr_port_to_string(addr, port), (void *) 0); } finish: nid_unref(node_id); }
/** * Free a tsync structure. */ static void tsync_free(struct tsync *ts) { g_assert(ts); g_assert(ts->magic == TSYNC_MAGIC); cq_cancel(&ts->expire_ev); nid_unref(ts->node_id); ts->magic = 0; WFREE(ts); }
static void node_data_free(gpointer value) { struct node_data *data = value; atom_str_free_null(&data->user_agent); WFREE_NULL(data->host, data->host_size); WFREE_NULL(data->info, data->info_size); nid_unref(data->node_id); WFREE(data); }
/** * Free routine for the extended message blocks we send to the UDP layer. */ static void g2_qh2_pmsg_free(pmsg_t *mb, void *arg) { struct g2_qh2_pmsg_info *pmi = arg; gnutella_node_t *n; g2_qh2_pmsg_info_check(pmi); g_assert(pmsg_is_extended(mb)); if (pmsg_was_sent(mb)) goto done; /* * Message was unsent, probably because the UDP address in the /Q2 was * wrong for some reason. * * If we're still connected to the hub which passed us this /Q2, then * we can relay back the /QH2 to the hub and it will hopefully be able * to deliver it back to the querying node. */ n = node_by_id(pmi->hub_id); if (NULL == n) { if (GNET_PROPERTY(g2_debug) > 1) { g_debug("%s(): could not send %s, relaying hub is gone, dropping.", G_STRFUNC, g2_msg_infostr_mb(mb)); } gnet_stats_inc_general(GNR_UDP_G2_HITS_UNDELIVERED); goto done; } else { pmsg_t *nmb; if (GNET_PROPERTY(g2_debug) > 1) { g_debug("%s(): could not send %s, giving back to %s for relaying", G_STRFUNC, g2_msg_infostr_mb(mb), node_infostr(n)); } nmb = pmsg_clone_plain(mb); pmsg_clear_reliable(nmb); g2_node_send(n, nmb); gnet_stats_inc_general(GNR_UDP_G2_HITS_REROUTED_TO_HUB); } done: nid_unref(pmi->hub_id); pmi->magic = 0; WFREE(pmi); }
static bool remove_item(hset_t *hs, const struct nid *node_id) { const void *orig_key; g_return_val_if_fail(hs, FALSE); g_return_val_if_fail(node_id, FALSE); if (hset_contains_extended(hs, node_id, &orig_key)) { hset_remove(hs, orig_key); nid_unref(orig_key); return TRUE; } else { return FALSE; } }
static G_GNUC_COLD void nodes_gui_remove_all_nodes(void) { GtkCList *clist; GList *iter; clist = GTK_CLIST(gui_main_window_lookup("clist_nodes")); g_return_if_fail(clist); gtk_clist_freeze(clist); for (iter = clist->row_list; NULL != iter; iter = g_list_next(iter)) { const struct nid *node_id = ((GtkCListRow *) iter->data)->data; nid_unref(node_id); } gtk_clist_thaw(clist); }
static gboolean remove_item(hset_t *hs, const struct nid *node_id) { void *orig_key; g_return_val_if_fail(hs, FALSE); g_return_val_if_fail(node_id, FALSE); orig_key = hset_lookup(hs, node_id); if (orig_key) { hset_remove(hs, orig_key); nid_unref(orig_key); return TRUE; } else { return FALSE; } }
/** * Free routine for a query message. */ static void sq_pmsg_free(pmsg_t *mb, void *arg) { struct smsg_info *smi = arg; g_assert(pmsg_is_extended(mb)); /* * If we're still in leaf mode, let the search know that we sent a * query for it to the specified node ID. */ if (settings_is_leaf()) search_notify_sent(smi->shandle, smi->node_id); nid_unref(smi->node_id); WFREE(smi); }
static void free_node_id(const void *key, void *unused_udata) { (void) unused_udata; nid_unref(key); }