/** * Record debugging configuration. */ void dbmw_set_debugging(dbmw_t *dw, const dbg_config_t *dbg) { dbmw_check(dw); dw->dbg = dbg; if (dbg_ds_debugging(dw->dbg, 1, DBG_DSF_DEBUGGING)) { dbg_ds_log(dw->dbg, dw, "%s: attached with %s back-end " "(max cached = %zu, key=%zu bytes, value=%zu bytes, " "%zu max serialized)", G_STRFUNC, dbmw_map_type(dw) == DBMAP_SDBM ? "sdbm" : "map", dw->max_cached, dw->key_size, dw->value_size, dw->value_data_size); } /* * Patch in place for the DBMAP. */ WFREE_TYPE_NULL(dw->dbmap_dbg); dw->dbmap_dbg = WCOPY(dbg); dw->dbmap_dbg->o2str = NULL; dw->dbmap_dbg->type = "DBMAP"; dbmap_set_debugging(dw->dm, dw->dbmap_dbg); }
static inline void udp_ping_free(struct udp_ping *ping) { WFREE_TYPE_NULL(ping->callback); atom_host_free_null(&ping->host); WFREE(ping); }
/** * Destroy the DBM wrapper, optionally closing the underlying DB map. */ void dbmw_destroy(dbmw_t *dw, bool close_map) { dbmw_check(dw); if (common_stats) { s_debug("DBMW destroying \"%s\" with %s back-end " "(read cache hits = %.2f%% on %s request%s, " "write cache hits = %.2f%% on %s request%s)", dw->name, dbmw_map_type(dw) == DBMAP_SDBM ? "sdbm" : "map", dw->r_hits * 100.0 / MAX(1, dw->r_access), uint64_to_string(dw->r_access), plural(dw->r_access), dw->w_hits * 100.0 / MAX(1, dw->w_access), uint64_to_string2(dw->w_access), plural(dw->w_access)); } if (dbg_ds_debugging(dw->dbg, 1, DBG_DSF_DESTROY)) { dbg_ds_log(dw->dbg, dw, "%s: with %s back-end " "(read cache hits = %.2f%% on %s request%s, " "write cache hits = %.2f%% on %s request%s)", G_STRFUNC, dbmw_map_type(dw) == DBMAP_SDBM ? "sdbm" : "map", dw->r_hits * 100.0 / MAX(1, dw->r_access), uint64_to_string(dw->r_access), plural(dw->r_access), dw->w_hits * 100.0 / MAX(1, dw->w_access), uint64_to_string2(dw->w_access), plural(dw->w_access)); } /* * If we close the map and we're volatile, there's no need to flush * the cache as the data is going to be gone soon anyway. */ if (!close_map || !dw->is_volatile) { dbmw_sync(dw, DBMW_SYNC_CACHE); } dbmw_clear_cache(dw); hash_list_free(&dw->keys); map_destroy(dw->values); if (dw->mb) pmsg_free(dw->mb); bstr_free(&dw->bs); if (close_map) dbmap_destroy(dw->dm); WFREE_TYPE_NULL(dw->dbmap_dbg); dw->magic = 0; WFREE(dw); }