@@ -134,7 +134,7 @@ main(void)
134134 int pipes [4 ];
135135 struct nc_session * sess ;
136136 struct lyd_node * op , * envp ;
137- struct ly_ctx * ctx ;
137+ struct ly_ctx * server_ctx , * client_ctx ;
138138 struct nc_rpc * rpc ;
139139 uint64_t msgid ;
140140 NC_MSG_TYPE msgtype ;
@@ -151,19 +151,23 @@ main(void)
151151 thread_arg .in = pipes [0 ];
152152 thread_arg .out = pipes [3 ];
153153
154- /* Create context */
155- nc_assert (ly_ctx_new (TESTS_DIR "/data/modules" , 0 , & ctx ) == LY_SUCCESS );
156- nc_assert (ly_ctx_load_module (ctx , "ietf-netconf" , NULL , features ));
157- nc_assert (ly_ctx_load_module (ctx , "notif1" , NULL , NULL ));
158- thread_arg .ctx = ctx ;
154+ /* Create both contexts */
155+ nc_assert (ly_ctx_new (TESTS_DIR "/data/modules" , 0 , & server_ctx ) == LY_SUCCESS );
156+ nc_assert (ly_ctx_load_module (server_ctx , "ietf-netconf" , NULL , features ));
157+ nc_assert (ly_ctx_load_module (server_ctx , "notif1" , NULL , NULL ));
158+ thread_arg .ctx = server_ctx ;
159159 nc_set_global_rpc_clb (rpc_clb );
160160
161+ nc_assert (ly_ctx_new (TESTS_DIR "/data/modules" , 0 , & client_ctx ) == LY_SUCCESS );
162+ nc_assert (ly_ctx_load_module (client_ctx , "ietf-netconf" , NULL , features ));
163+ nc_assert (ly_ctx_load_module (client_ctx , "notif1" , NULL , NULL ));
164+
161165 /* Start server thread */
162166 pthread_create (& t [0 ], NULL , server_thread , & thread_arg );
163167 nc_client_init ();
164168
165169 /* Listen for notifications */
166- sess = nc_connect_inout (pipes [2 ], pipes [1 ], ctx );
170+ sess = nc_connect_inout (pipes [2 ], pipes [1 ], client_ctx );
167171 nc_assert (sess );
168172 pthread_create (& t [1 ], NULL , notif_thread , sess );
169173
@@ -187,7 +191,8 @@ main(void)
187191
188192 /* Cleanup */
189193 nc_session_free (sess , NULL );
190- ly_ctx_destroy (ctx );
194+ ly_ctx_destroy (server_ctx );
195+ ly_ctx_destroy (client_ctx );
191196 for (uint8_t i = 0 ; i < 4 ; i ++ ) {
192197 close (pipes [i ]);
193198 }
0 commit comments