void smbprofile_persvc_unref(int snum);
struct profile_stats *smbprofile_persvc_get(int snum);
+int smbprofile_persvc_collect(int (*fn)(const char *key,
+ const struct profile_stats *stats,
+ void *private_data),
+ void *private_data);
+
+int smbprofile_persvc_collect_tdb(struct tdb_context *tdb,
+ int (*fn)(const char *,
+ const struct profile_stats *,
+ void *),
+ void *userp);
+
#define START_PROFILE_X(_snum, x) \
struct smbprofile_stats_basic_async __profasync_##x = {}; \
struct smbprofile_stats_basic_async __profasync_persvc_##x = {}; \
}
}
+int smbprofile_persvc_collect(int (*fn)(const char *key,
+ const struct profile_stats *stats,
+ void *private_data),
+ void *private_data)
+{
+ if (smbprofile_state.internal.db == NULL) {
+ return 0;
+ }
+ return smbprofile_persvc_collect_tdb(smbprofile_state.internal.db->tdb,
+ fn,
+ private_data);
+}
return state.num_workers;
}
+
+struct smbprofile_persvc_collector {
+ int (*cb)(const char *, const struct profile_stats *, void *);
+ void *userp;
+ int ret;
+};
+
+static int smbprofile_persvc_collect_fn(struct tdb_context *tdb,
+ TDB_DATA key,
+ TDB_DATA value,
+ void *private_data)
+{
+
+ const struct profile_stats *stats = NULL;
+ struct smbprofile_persvc_collector *col = NULL;
+
+ if (key.dsize < 5) {
+ return 0;
+ }
+
+ if (value.dsize != sizeof(*stats)) {
+ return 0;
+ }
+
+ col = (struct smbprofile_persvc_collector *)private_data;
+ stats = (const struct profile_stats *)(value.dptr);
+
+ col->ret = col->cb((const char *)key.dptr, stats, col->userp);
+ return (col->ret == 0) ? 0 : -1;
+}
+
+int smbprofile_persvc_collect_tdb(struct tdb_context *tdb,
+ int (*fn)(const char *,
+ const struct profile_stats *,
+ void *),
+ void *userp)
+{
+ struct smbprofile_persvc_collector col = {
+ .cb = fn,
+ .userp = userp,
+ .ret = 0,
+ };
+
+ tdb_traverse_read(tdb, smbprofile_persvc_collect_fn, &col);
+ return col.ret;
+}