netopeer2 icon indicating copy to clipboard operation
netopeer2 copied to clipboard

Notifications failing while acquiring context

Open jbn98 opened this issue 2 years ago • 3 comments

Hi Team

I am using below packages

libnetconf2-2.1.28 libyang-2.1.30 netopeer2-2.1.49 sysrepo-2.2.36

While sending the notification to the client I have observed some errors from the sysrepo. It says the 'failed to acquire context'. I will attach the error messages and the code snippet. Can you kindly look into this and tell me what I might be doing wrong and causing the issue. Thank you for you help in advance

------------CODE SNIPPET--------------

void                                                                            
notifyClient (void)                                                             
{                                                                               
                                                                                
    struct lyd_node *notif = NULL;                                              
#if (SYSREPO_VERSION == SYSREPO_v1_x_x)                                         
                                                                                
    /* Create the notification */                                               
    notif = lyd_new_path (                                                      
        NULL,                                                                   
        sr_get_context (sr_session_get_connection (global_pri_data->session)),  
        SUPERVISION_NOTIF_XPATH, NULL, 0, 0);                                   
#elif (SYSREPO_VERSION == SYSREPO_v2_x_x)                                       
                                                                                
    /* Create the notification */                                               
    const struct ly_ctx *ctx = sr_session_acquire_context(global_pri_data->session);
    if (ctx == NULL)                                                            
        {                                                                       
            PRINT(ERR, program_invocation_short_name,                           
                    "Failed to acquire context%s", "\n");                       
            return;                                                             
        }                                                                       
    lyd_new_path (                                                              
        NULL,                                                                   
        ctx,                                                                    
        SUPERVISION_NOTIF_XPATH, NULL, 0, &notif);                              
#endif                                                                          
    if (notif == NULL)                                                          
        {                                                                       
            PRINT (ERR, program_invocation_short_name, "lyd_new_path failed%s", 
                   "\n");                                                       
            return;                                                             
        }                                                                       
                                                                                
    /* Send the notification */                                                 
    if (SR_NOTIF_SEND_TREE (global_pri_data->session, notif, 0, 0) != SR_ERR_OK)
        {                                                                       
            PRINT (ERR, program_invocation_short_name,                          
                "Failed to send the notification%s", "\n");                     
        }                                                                       
    if (notif != NULL)                                                          
        {                                                                       
            LYD_FREE_API (notif);                                               
            sr_session_release_context(global_pri_data->session);               
        }                                                                       
                                                                                
    return;                                                                     
}      

------------------ERROR LOGS--------------------

[ERR] Internal error (/usr/src/debug/sysrepo-2-x-x/v2.2.36-r0/git/src/common.c:4185).
[ERR] Locking a mutex failed (sr_acquire_context: Connection timed out).
[ERR] Internal error (/usr/src/debug/sysrepo-2-x-x/v2.2.36-r0/git/src/common.c:4264).
ERR (supervision): Failed to acquire context
ERR (supervision): lyd_new_path failed
[ERR] Locking a mutex failed (sr_release_context: Connection timed out).

jbn98 avatar Aug 04 '23 05:08 jbn98