mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Make periodic notification check under ulooop
This commit is contained in:
parent
24f856aad7
commit
4a2693856b
4 changed files with 28 additions and 30 deletions
2
config.c
2
config.c
|
|
@ -49,7 +49,7 @@ int get_global_config()
|
|||
int error, error2, error3;
|
||||
char *value = NULL, *value2 = NULL, *value3 = NULL;
|
||||
|
||||
cwmp_main.conf.cr_auth_type = AUTH_DIGEST;
|
||||
//cwmp_main->conf.cr_auth_type = AUTH_DIGEST;
|
||||
if ((error = uci_get_value(UCI_CPE_LOG_FILE_NAME, &value)) == CWMP_OK) {
|
||||
if (value != NULL) {
|
||||
log_set_log_file_name(value);
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ extern struct list_head list_lw_value_change;
|
|||
extern struct list_head list_value_change;
|
||||
extern pthread_mutex_t mutex_value_change;
|
||||
extern struct list_head list_param_obj_notify;
|
||||
extern struct uloop_timeout check_notify_timer;
|
||||
|
||||
/*#define foreach_parameter_notification(function, parameter, notification) \
|
||||
#ifndef NOTIF_VARIABLES_##function \
|
||||
|
|
@ -70,4 +71,6 @@ void clean_list_param_notify();
|
|||
void init_list_param_notify();
|
||||
void reinit_list_param_notify();
|
||||
void cwmp_prepare_value_change();
|
||||
void periodic_check_notifiy(struct uloop_timeout *timeout __attribute__((unused)));
|
||||
void trigger_periodic_notify_check();
|
||||
#endif /* SRC_INC_NOTIFICATIONS_H_ */
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ LIST_HEAD(list_value_change);
|
|||
LIST_HEAD(list_lw_value_change);
|
||||
LIST_HEAD(list_param_obj_notify);
|
||||
pthread_mutex_t mutex_value_change = PTHREAD_MUTEX_INITIALIZER;
|
||||
struct uloop_timeout check_notify_timer = { .cb = periodic_check_notifiy };
|
||||
|
||||
char *notifications[7] = {"disabled" , "passive", "active", "passive_lw", "passive_passive_lw", "active_lw", "passive_active_lw"};
|
||||
|
||||
|
|
@ -567,24 +568,12 @@ void sotfware_version_value_change(struct transfer_complete *p)
|
|||
}
|
||||
}
|
||||
|
||||
void *thread_periodic_check_notify(void *v __attribute__((unused)))
|
||||
void periodic_check_notifiy(struct uloop_timeout *timeout __attribute__((unused)))
|
||||
{
|
||||
//static int periodic_interval;
|
||||
static bool periodic_enable;
|
||||
int periodic_interval = cwmp_main->conf.periodic_notify_interval;
|
||||
int is_notify = 0;
|
||||
|
||||
//periodic_interval = cwmp_main->conf.periodic_notify_interval;
|
||||
periodic_enable = cwmp_main->conf.periodic_notify_enable;
|
||||
|
||||
for (;;) {
|
||||
if (periodic_enable) {
|
||||
// pthread_mutex_lock(&(cwmp_main->mutex_notify_periodic));
|
||||
|
||||
if (cwmp_stop)
|
||||
break;
|
||||
|
||||
//pthread_cond_timedwait(&(cwmp_main->threshold_notify_periodic), &(cwmp_main->mutex_notify_periodic), &periodic_timeout);
|
||||
|
||||
return;
|
||||
is_notify = check_value_change();
|
||||
if (is_notify > 0)
|
||||
cwmp_update_enabled_notify_file();
|
||||
|
|
@ -592,11 +581,13 @@ void *thread_periodic_check_notify(void *v __attribute__((unused)))
|
|||
send_active_value_change();
|
||||
if (is_notify & NOTIF_LW_ACTIVE)
|
||||
cwmp_lwnotification();
|
||||
//pthread_mutex_unlock(&(cwmp_main->mutex_notify_periodic));
|
||||
} else
|
||||
break;
|
||||
|
||||
uloop_timeout_set(&check_notify_timer, cwmp_main->conf.periodic_notify_interval * 1000);
|
||||
}
|
||||
return NULL;
|
||||
|
||||
void trigger_periodic_notify_check()
|
||||
{
|
||||
uloop_timeout_set(&check_notify_timer, 10);
|
||||
}
|
||||
|
||||
void add_list_value_change(char *param_name, char *param_data, char *param_type)
|
||||
|
|
|
|||
10
session.c
10
session.c
|
|
@ -94,7 +94,7 @@ int cwmp_session_exit()
|
|||
|
||||
static int cwmp_rpc_cpe_handle_message(struct rpc *rpc_cpe)
|
||||
{
|
||||
if (xml_prepare_msg_out(cwmp_main->session))
|
||||
if (xml_prepare_msg_out())
|
||||
return -1;
|
||||
|
||||
if (rpc_cpe_methods[rpc_cpe->type].handler(rpc_cpe))
|
||||
|
|
@ -236,12 +236,14 @@ void start_cwmp_session()
|
|||
char *exec_download = NULL;
|
||||
int is_notify = 0;
|
||||
|
||||
uloop_timeout_cancel(&check_notify_timer);
|
||||
if (cwmp_session_init() != CWMP_OK) {
|
||||
CWMP_LOG(ERROR, "Not able to init a CWMP session");
|
||||
t = cwmp_get_session_retry_interval();
|
||||
CWMP_LOG(INFO, "Retry session, retry count = %d, retry in %ds", cwmp_main->retry_count_session, t);
|
||||
set_cwmp_session_status(SESSION_FAILURE, t);
|
||||
uloop_timeout_set(&retry_session_timer, 1000 * t);
|
||||
trigger_periodic_notify_check();
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -281,6 +283,7 @@ void start_cwmp_session()
|
|||
|
||||
if (cwmp_stop) {
|
||||
event_remove_all_event_container(RPC_SEND);
|
||||
event_remove_all_event_container(RPC_QUEUE);
|
||||
run_session_end_func();
|
||||
return;
|
||||
}
|
||||
|
|
@ -293,13 +296,14 @@ void start_cwmp_session()
|
|||
uloop_timeout_set(&retry_session_timer, 1000 * t);
|
||||
} else {
|
||||
event_remove_all_event_container(RPC_SEND);
|
||||
event_remove_all_event_container(RPC_QUEUE);
|
||||
cwmp_main->retry_count_session = 0;
|
||||
set_cwmp_session_status(SESSION_SUCCESS, 0);
|
||||
}
|
||||
run_session_end_func();
|
||||
cwmp_session_exit();
|
||||
CWMP_LOG(INFO, "Waiting the next session");
|
||||
|
||||
trigger_periodic_notify_check();
|
||||
}
|
||||
|
||||
void trigger_cwmp_session_timer()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue