#include <assert.h>
#include <errno.h>
+#include "bitmap.h"
#include "column.h"
#include "json.h"
#include "jsonrpc.h"
static void ovsdb_jsonrpc_session_run_all(struct ovsdb_jsonrpc_remote *);
static void ovsdb_jsonrpc_session_wait_all(struct ovsdb_jsonrpc_remote *);
static void ovsdb_jsonrpc_session_close_all(struct ovsdb_jsonrpc_remote *);
+static void ovsdb_jsonrpc_session_reconnect_all(struct ovsdb_jsonrpc_remote *);
/* Triggers. */
static void ovsdb_jsonrpc_trigger_create(struct ovsdb_jsonrpc_session *,
struct pstream *listener;
int error;
- error = pstream_open(name, &listener);
+ error = jsonrpc_pstream_open(name, &listener);
if (error && error != EAFNOSUPPORT) {
VLOG_ERR_RL(&rl, "%s: listen failed: %s", name, strerror(error));
return;
free(remote);
}
+/* Forces all of the JSON-RPC sessions managed by 'svr' to disconnect and
+ * reconnect. */
+void
+ovsdb_jsonrpc_server_reconnect(struct ovsdb_jsonrpc_server *svr)
+{
+ struct shash_node *node;
+
+ SHASH_FOR_EACH (node, &svr->remotes) {
+ struct ovsdb_jsonrpc_remote *remote = node->data;
+
+ ovsdb_jsonrpc_session_reconnect_all(remote);
+ }
+}
+
void
ovsdb_jsonrpc_server_run(struct ovsdb_jsonrpc_server *svr)
{
}
}
+/* Forces all of the JSON-RPC sessions managed by 'remote' to disconnect and
+ * reconnect. */
+static void
+ovsdb_jsonrpc_session_reconnect_all(struct ovsdb_jsonrpc_remote *remote)
+{
+ struct ovsdb_jsonrpc_session *s, *next;
+
+ LIST_FOR_EACH_SAFE (s, next, struct ovsdb_jsonrpc_session, node,
+ &remote->sessions) {
+ jsonrpc_session_force_reconnect(s->js);
+ if (!jsonrpc_session_is_alive(s->js)) {
+ ovsdb_jsonrpc_session_close(s);
+ }
+ }
+}
+
static const char *
get_db_name(const struct ovsdb_jsonrpc_session *s)
{
static bool
ovsdb_jsonrpc_monitor_change_cb(const struct ovsdb_row *old,
const struct ovsdb_row *new,
+ const unsigned long int *changed,
void *aux_)
{
struct ovsdb_jsonrpc_monitor_aux *aux = aux_;
for (i = 0; i < aux->mt->columns.n_columns; i++) {
const struct ovsdb_column *column = aux->mt->columns.columns[i];
unsigned int idx = column->index;
- bool changed = false;
+ bool column_changed = false;
if (type == OJMS_MODIFY) {
- changed = !ovsdb_datum_equals(&old->fields[idx],
- &new->fields[idx], &column->type);
- n_changed += changed;
+ column_changed = bitmap_is_set(changed, idx);
+ n_changed += column_changed;
}
- if (changed || type == OJMS_DELETE) {
+ if (column_changed || type == OJMS_DELETE) {
if (!old_json) {
old_json = json_object_create();
}
static struct ovsdb_error *
ovsdb_jsonrpc_monitor_commit(struct ovsdb_replica *replica,
- const struct ovsdb_txn *txn, bool durable UNUSED)
+ const struct ovsdb_txn *txn,
+ bool durable OVS_UNUSED)
{
struct ovsdb_jsonrpc_monitor *m = ovsdb_jsonrpc_monitor_cast(replica);
struct ovsdb_jsonrpc_monitor_aux aux;
HMAP_FOR_EACH (row, struct ovsdb_row, hmap_node,
&mt->table->rows) {
- ovsdb_jsonrpc_monitor_change_cb(NULL, row, &aux);
+ ovsdb_jsonrpc_monitor_change_cb(NULL, row, NULL, &aux);
}
}
}