Skip to content

Commit 77bc35d

Browse files
samuel-gauthierrjarry
authored andcommitted
session: fix rpc_send_ly dnode free function
When rpc_send_ly is called more that 255 times in the same session, it fails, because the context has been acquired too many times. The new_dnode function can not be used for rpc_send_ly because it does not free the output node, it only frees output.tree. Use a mechanism similar to get_data_ly, i.e free the output node returned by sr_rpc_send_tree, call sr_release_data on it as well, and release the context that was used by our new dnode. Signed-off-by: Samuel Gauthier <[email protected]>
1 parent 02e6cf7 commit 77bc35d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

sysrepo/session.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,17 @@ def rpc_send_ly(
14721472
if not sr_data_p[0]:
14731473
raise SysrepoInternalError("sr_rpc_send_tree returned NULL")
14741474

1475-
return self.new_dnode(sr_data_p[0].tree)
1475+
ctx = self.acquire_context()
1476+
dnode = libyang.DNode.new(ctx, sr_data_p[0].tree)
1477+
1478+
# customize the free method to use the sysrepo free
1479+
def sysrepo_free(dnode_src):
1480+
lib.sr_release_data(sr_data_p[0])
1481+
self.release_context()
1482+
1483+
dnode.free_func = sysrepo_free
1484+
1485+
return dnode
14761486

14771487
def rpc_send(
14781488
self,

0 commit comments

Comments
 (0)