Skip to content

Commit

Permalink
Optimization on connect: do not do post processing of shared YANGs
Browse files Browse the repository at this point in the history
  • Loading branch information
olofhagsand committed Jun 12, 2024
1 parent 150988f commit 4bb5d91
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions src/controller_device_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -889,13 +889,8 @@ device_shared_yspec(clixon_handle h,
yang_ref_inc(yspec); /* share */
}
}
if (yspec1){
if (yspec == NULL) {
if ((yspec = yspec_new()) == NULL) // 3
goto done;
}
if (yspec1)
*yspec1 = yspec;
}
retval = 0;
done:
return retval;
Expand Down Expand Up @@ -1093,6 +1088,7 @@ device_state_handler(clixon_handle h,
cbuf *cberr = NULL;
cbuf *cbmsg;
cxobj *xyanglib;
int yspec_shared = 0;

rpcname = xml_name(xmsg);
conn_state = device_handle_conn_state_get(dh);
Expand Down Expand Up @@ -1151,16 +1147,24 @@ device_state_handler(clixon_handle h,
if (yspec1 == NULL){
if (device_shared_yspec(h, dh, xyanglib, &yspec1) < 0)
goto done;
if (yspec1 == NULL){
if ((yspec1 = yspec_new()) == NULL)
goto done;
}
else
yspec_shared++;
if (controller_mount_yspec_set(h, name, yspec1) < 0)
goto done;
}
/* All schemas ready, parse them (may do device_close) */
if ((ret = device_schemas_mount_parse(h, dh, xyanglib)) < 0)
goto done;
if (ret == 0){
if (controller_transaction_failed(h, tid, ct, dh, TR_FAILED_DEV_LEAVE, name, device_handle_logmsg_get(dh)) < 0)
if (yspec_shared == 0){
if ((ret = device_schemas_mount_parse(h, dh, xyanglib)) < 0)
goto done;
break;
if (ret == 0){
if (controller_transaction_failed(h, tid, ct, dh, TR_FAILED_DEV_LEAVE, name, device_handle_logmsg_get(dh)) < 0)
goto done;
break;
}
}
/* Unconditionally sync */
if (device_send_get_config(h, dh, s) < 0)
Expand Down Expand Up @@ -1205,20 +1209,28 @@ device_state_handler(clixon_handle h,
if (yspec1 == NULL){
if (device_shared_yspec(h, dh, xyanglib, &yspec1) < 0)
goto done;
if (yspec1 == NULL){
if ((yspec1 = yspec_new()) == NULL)
goto done;
}
else
yspec_shared++;
if (controller_mount_yspec_set(h, name, yspec1) < 0)
goto done;
}
nr = 0;
if ((ret = device_send_get_schema_next(h, dh, s, &nr)) < 0)
goto done;
if (ret == 0){ /* None found */
/* All schemas ready, parse them */
if ((ret = device_schemas_mount_parse(h, dh, xyanglib)) < 0)
goto done;
if (ret == 0){
if (controller_transaction_failed(h, tid, ct, dh, TR_FAILED_DEV_LEAVE, name, device_handle_logmsg_get(dh)) < 0)
if (yspec_shared == 0){
/* All schemas ready, parse them */
if ((ret = device_schemas_mount_parse(h, dh, xyanglib)) < 0)
goto done;
break;
if (ret == 0){
if (controller_transaction_failed(h, tid, ct, dh, TR_FAILED_DEV_LEAVE, name, device_handle_logmsg_get(dh)) < 0)
goto done;
break;
}
}
/* Unconditionally sync */
if (device_send_get_config(h, dh, s) < 0)
Expand Down

0 comments on commit 4bb5d91

Please sign in to comment.