/** * Iterator over the table: apply function on each entry. * * The table is traversed in the order of keys. */ void ohash_table_foreach(const ohash_table_t *oh, keyval_fn_t func, void *data) { struct ohash_foreach_ctx ctx; ctx.func = func; ctx.data = data; hash_list_foreach(oh->hl, ohash_table_foreach_helper, &ctx); }
/** * Apply function to each attribute, in the order they were defined. */ void xattr_table_foreach(const xattr_table_t *xat, xattr_table_cb_t func, void *data) { struct xattr_table_foreach_ctx ctx; xattr_table_check(xat); ctx.func = func; ctx.data = data; hash_list_foreach(xat->hl, xattr_table_foreach_wrap, &ctx); }
/** * Trigger TX stack servicing. */ static void udp_sched_service(udp_sched_t *us, struct udp_service_ctx *ctx) { udp_sched_check(us); udp_sched_log(4, "%p", us); /* * We don't want to service the TX queues that attached to us in the same * order to avoid nasty starving effects, hence rotate the list each time * we service it. */ hash_list_rotate_left(us->stacks); hash_list_foreach(us->stacks, udp_sched_tx_service, ctx); }
/** * Save upload statistics to file. */ static void upload_stats_dump_history(void) { FILE *out; file_path_t fp; /* open file for writing */ file_path_set(&fp, settings_config_dir(), ul_stats_file); out = file_config_open_write(ul_stats_what, &fp); if (NULL == out) return; file_config_preamble(out, "Upload statistics"); fputs( "#\n" "# Format is:\n" "# File basename <TAB> size <TAB> attempts <TAB> completed\n" "# <TAB> bytes_sent-high <TAB> bytes_sent-low\n" "# <TAB> time of last request <TAB> time of last served chunk\n" "# <TAB> SHA1 (\"*\" if unknown)\n" "#\n" "\n", out ); /* * Don't check this sooner so that the file is cleared, if the user * cleared the history. */ if (upload_stats_list) { /* for each element in uploads_stats_list, write out to hist file */ hash_list_foreach(upload_stats_list, upload_stats_dump_item, out); } file_config_close(out, &fp); dirty = FALSE; }