Skip to content

Commit

Permalink
session: fix rpc_send_ly dnode free function
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
samuel-gauthier authored and rjarry committed Feb 1, 2024
1 parent 02e6cf7 commit 77bc35d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion sysrepo/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,17 @@ def rpc_send_ly(
if not sr_data_p[0]:
raise SysrepoInternalError("sr_rpc_send_tree returned NULL")

return self.new_dnode(sr_data_p[0].tree)
ctx = self.acquire_context()
dnode = libyang.DNode.new(ctx, sr_data_p[0].tree)

# customize the free method to use the sysrepo free
def sysrepo_free(dnode_src):
lib.sr_release_data(sr_data_p[0])
self.release_context()

dnode.free_func = sysrepo_free

return dnode

def rpc_send(
self,
Expand Down

0 comments on commit 77bc35d

Please sign in to comment.