Skip to content

Commit

Permalink
Fixed latest optimization, moved datastore operation from loop
Browse files Browse the repository at this point in the history
  • Loading branch information
olofhagsand committed May 3, 2024
1 parent 971e2e9 commit f3c6b56
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/controller_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,6 @@ controller_connect(clixon_handle h,
goto done;
}
}
if (xmldb_db_reset(h, "tmpdev") < 0) /* Requires root access */
goto done;
if (xmldb_copy(h, "running", "tmpdev") < 0)
goto done;
/* Point of no return: assume errors handled in device_input_cb */
device_handle_tid_set(dh, ct->ct_id);
if (connect_netconf_ssh(h, dh, user, addr, ssh_stricthostkey) < 0) /* match */
Expand Down Expand Up @@ -1613,6 +1609,7 @@ rpc_connection_change(clixon_handle h,
cbuf *cbtr = NULL;
char *reason = NULL;
int ret;
int tmpdev = 0;

clixon_debug(CLIXON_DBG_CTRL, "%s", __FUNCTION__);
if ((cbtr = cbuf_new()) == NULL){
Expand Down Expand Up @@ -1664,6 +1661,7 @@ rpc_connection_change(clixon_handle h,
goto done;
goto ok;
}
tmpdev++;
}
}
else if (strcmp(operation, "RECONNECT") == 0){
Expand All @@ -1681,13 +1679,22 @@ rpc_connection_change(clixon_handle h,
goto done;
goto ok;
}
tmpdev++;
}
}
else {
clixon_err(OE_NETCONF, 0, "%s is not a connection-operation", operation);
goto done;
}
} /* for */
/* Initiate tmpdev datastore for device commits */
if (tmpdev) {
/* Possibly only copy files / dir */
if (xmldb_db_reset(h, "tmpdev") < 0) /* Requires root access */
goto done;
if (xmldb_copy(h, "running", "tmpdev") < 0)
goto done;
}
cprintf(cbret, "<rpc-reply xmlns=\"%s\">", NETCONF_BASE_NAMESPACE);
cprintf(cbret, "<tid xmlns=\"%s\">%" PRIu64"</tid>", CONTROLLER_NAMESPACE, ct->ct_id);
cprintf(cbret, "</rpc-reply>");
Expand Down

0 comments on commit f3c6b56

Please sign in to comment.