Commit
4c2809787cdbc774 (ovsdb-monitor: add json cache) introduced
an optimization that allows jsonrpc session to share monitors.
However, the memory/show implementation was not updated to match the
implementation; it still assumes that each jsonrpc session uses its
own monitor, thus are likely to over reporting the number.
This patch fix the bug and reports the actual number of monitor used
by the ovsdb-server.
Signed-off-by: Andy Zhou <azhou@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
struct simap *usage)
{
simap_increase(usage, "triggers", hmap_count(&s->triggers));
- simap_increase(usage, "monitors", hmap_count(&s->monitors));
simap_increase(usage, "backlog", jsonrpc_session_get_backlog(s->js));
}
}
}
+/* Add some memory usage statics for monitors into 'usage', for use with
+ * memory_report(). */
+void
+ovsdb_monitor_get_memory_usage(struct simap *usage)
+{
+ simap_put(usage, "monitors", hmap_count(&ovsdb_monitors));
+}
+
static const struct ovsdb_replica_class ovsdb_jsonrpc_replica_class = {
ovsdb_monitor_commit,
ovsdb_monitor_destroy_callback,
uint64_t next_transaction);
void ovsdb_monitor_get_initial(const struct ovsdb_monitor *dbmon);
+
+void ovsdb_monitor_get_memory_usage(struct simap *usage);
#endif
#include "jsonrpc-server.h"
#include "list.h"
#include "memory.h"
+#include "monitor.h"
#include "ovsdb.h"
#include "ovsdb-data.h"
#include "ovsdb-types.h"
simap_init(&usage);
ovsdb_jsonrpc_server_get_memory_usage(jsonrpc, &usage);
+ ovsdb_monitor_get_memory_usage(&usage);
SHASH_FOR_EACH(node, all_dbs) {
struct db *db = node->data;
ovsdb_get_memory_usage(db->db, &usage);