@@ -3812,11 +3812,11 @@ nc_server_config_ln2_netconf_server(const struct lyd_node *node, NC_OPERATION op
38123812
38133813#ifdef NC_ENABLED_SSH_TLS
38143814 /* delete the intervals */
3815- pthread_mutex_lock (& server_opts .cert_exp_notif_thread_lock );
3816- free (server_opts .intervals );
3817- server_opts .intervals = NULL ;
3818- server_opts .interval_count = 0 ;
3819- pthread_mutex_unlock (& server_opts .cert_exp_notif_thread_lock );
3815+ pthread_mutex_lock (& server_opts .cert_exp_notif . lock );
3816+ free (server_opts .cert_exp_notif . intervals );
3817+ server_opts .cert_exp_notif . intervals = NULL ;
3818+ server_opts .cert_exp_notif . interval_count = 0 ;
3819+ pthread_mutex_unlock (& server_opts .cert_exp_notif . lock );
38203820#endif /* NC_ENABLED_SSH_TLS */
38213821
38223822 }
@@ -3861,22 +3861,27 @@ nc_server_config_create_interval(const char *anchor, const char *period)
38613861 int ret = 0 ;
38623862 struct nc_cert_exp_time cert_exp_time = {0 };
38633863
3864- server_opts .intervals = nc_realloc (server_opts .intervals , (server_opts .interval_count + 1 ) * sizeof * server_opts .intervals );
3865- NC_CHECK_ERRMEM_RET (!server_opts .intervals , 1 );
3864+ server_opts .cert_exp_notif .intervals = nc_realloc (server_opts .cert_exp_notif .intervals ,
3865+ (server_opts .cert_exp_notif .interval_count + 1 ) * sizeof * server_opts .cert_exp_notif .intervals );
3866+ NC_CHECK_ERRMEM_RET (!server_opts .cert_exp_notif .intervals , 1 );
38663867
3868+ /* convert and set the anchor */
38673869 ret = nc_server_config_yang_value2cert_exp_time (anchor , & cert_exp_time );
38683870 if (ret ) {
38693871 goto cleanup ;
38703872 }
3871- memcpy (& server_opts .intervals [server_opts .interval_count ].anchor , & cert_exp_time , sizeof cert_exp_time );
3873+ memcpy (& server_opts .cert_exp_notif .intervals [server_opts .cert_exp_notif .interval_count ].anchor ,
3874+ & cert_exp_time , sizeof cert_exp_time );
38723875
3876+ /* convert and set the period */
38733877 ret = nc_server_config_yang_value2cert_exp_time (period , & cert_exp_time );
38743878 if (ret ) {
38753879 goto cleanup ;
38763880 }
3877- memcpy (& server_opts .intervals [server_opts .interval_count ].period , & cert_exp_time , sizeof cert_exp_time );
3881+ memcpy (& server_opts .cert_exp_notif .intervals [server_opts .cert_exp_notif .interval_count ].period ,
3882+ & cert_exp_time , sizeof cert_exp_time );
38783883
3879- ++ server_opts .interval_count ;
3884+ ++ server_opts .cert_exp_notif . interval_count ;
38803885
38813886cleanup :
38823887 return ret ;
@@ -3895,23 +3900,25 @@ nc_server_config_del_interval(const char *anchor, const char *period)
38953900 return ;
38963901 }
38973902
3898- for (i = 0 ; i < server_opts .interval_count ; ++ i ) {
3899- if (!memcmp (& server_opts .intervals [i ].anchor , & anchor_time , sizeof anchor_time ) &&
3900- !memcmp (& server_opts .intervals [i ].period , & period_time , sizeof period_time )) {
3903+ for (i = 0 ; i < server_opts .cert_exp_notif . interval_count ; ++ i ) {
3904+ if (!memcmp (& server_opts .cert_exp_notif . intervals [i ].anchor , & anchor_time , sizeof anchor_time ) &&
3905+ !memcmp (& server_opts .cert_exp_notif . intervals [i ].period , & period_time , sizeof period_time )) {
39013906 break ;
39023907 }
39033908 }
3904- if (i == server_opts .interval_count ) {
3909+ if (i == server_opts .cert_exp_notif . interval_count ) {
39053910 ERR (NULL , "Interval \"%s %s\" not found." , anchor , period );
39063911 return ;
39073912 }
39083913
3909- server_opts .interval_count -- ;
3910- if (!server_opts .interval_count ) {
3911- free (server_opts .intervals );
3912- server_opts .intervals = NULL ;
3913- } else if (i != server_opts .interval_count ) {
3914- memcpy (& server_opts .intervals [i ], & server_opts .intervals [server_opts .interval_count ], sizeof * server_opts .intervals );
3914+ server_opts .cert_exp_notif .interval_count -- ;
3915+ if (!server_opts .cert_exp_notif .interval_count ) {
3916+ free (server_opts .cert_exp_notif .intervals );
3917+ server_opts .cert_exp_notif .intervals = NULL ;
3918+ } else if (i != server_opts .cert_exp_notif .interval_count ) {
3919+ memcpy (& server_opts .cert_exp_notif .intervals [i ],
3920+ & server_opts .cert_exp_notif .intervals [server_opts .cert_exp_notif .interval_count ],
3921+ sizeof * server_opts .cert_exp_notif .intervals );
39153922 }
39163923}
39173924
@@ -3929,7 +3936,7 @@ nc_server_config_interval(const struct lyd_node *node, NC_OPERATION op)
39293936 assert (period );
39303937
39313938 /* LOCK */
3932- pthread_mutex_lock (& server_opts .cert_exp_notif_thread_lock );
3939+ pthread_mutex_lock (& server_opts .cert_exp_notif . lock );
39333940
39343941 if ((op == NC_OP_CREATE ) || (op == NC_OP_REPLACE )) {
39353942 ret = nc_server_config_create_interval (lyd_get_value (anchor ), lyd_get_value (period ));
@@ -3941,7 +3948,7 @@ nc_server_config_interval(const struct lyd_node *node, NC_OPERATION op)
39413948 }
39423949
39433950cleanup :
3944- pthread_mutex_unlock (& server_opts .cert_exp_notif_thread_lock );
3951+ pthread_mutex_unlock (& server_opts .cert_exp_notif . lock );
39453952 return ret ;
39463953}
39473954
@@ -4238,11 +4245,11 @@ nc_server_config_setup_diff(const struct lyd_node *data)
42384245
42394246#ifdef NC_ENABLED_SSH_TLS
42404247 /* wake up the cert expiration notif thread if it's running */
4241- pthread_mutex_lock (& server_opts .cert_exp_notif_thread_lock );
4242- if (server_opts .cert_exp_notif_thread_running ) {
4243- pthread_cond_signal (& server_opts .cert_exp_notif_thread_cond );
4248+ pthread_mutex_lock (& server_opts .cert_exp_notif . lock );
4249+ if (server_opts .cert_exp_notif . thread_running ) {
4250+ pthread_cond_signal (& server_opts .cert_exp_notif . cond );
42444251 }
4245- pthread_mutex_unlock (& server_opts .cert_exp_notif_thread_lock );
4252+ pthread_mutex_unlock (& server_opts .cert_exp_notif . lock );
42464253#endif /* NC_ENABLED_SSH_TLS */
42474254
42484255cleanup :
@@ -4319,11 +4326,11 @@ nc_server_config_setup_data(const struct lyd_node *data)
43194326
43204327#ifdef NC_ENABLED_SSH_TLS
43214328 /* wake up the cert expiration notif thread if it's running */
4322- pthread_mutex_lock (& server_opts .cert_exp_notif_thread_lock );
4323- if (server_opts .cert_exp_notif_thread_running ) {
4324- pthread_cond_signal (& server_opts .cert_exp_notif_thread_cond );
4329+ pthread_mutex_lock (& server_opts .cert_exp_notif . lock );
4330+ if (server_opts .cert_exp_notif . thread_running ) {
4331+ pthread_cond_signal (& server_opts .cert_exp_notif . cond );
43254332 }
4326- pthread_mutex_unlock (& server_opts .cert_exp_notif_thread_lock );
4333+ pthread_mutex_unlock (& server_opts .cert_exp_notif . lock );
43274334#endif /* NC_ENABLED_SSH_TLS */
43284335
43294336cleanup :
0 commit comments