mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
fix issus
This commit is contained in:
parent
84aa0daccf
commit
2d255e0b1d
5 changed files with 55 additions and 26 deletions
1
config.c
1
config.c
|
|
@ -801,6 +801,7 @@ int cwmp_init(int argc, char** argv,struct cwmp *cwmp)
|
|||
pthread_mutex_init(&cwmp->mutex_periodic, NULL);
|
||||
pthread_mutex_init(&cwmp->mutex_session_queue, NULL);
|
||||
pthread_mutex_init(&cwmp->mutex_session_send, NULL);
|
||||
pthread_mutex_init(&cwmp->mutex_handle_notify, NULL);
|
||||
memcpy(&(cwmp->env),&env,sizeof(struct env));
|
||||
INIT_LIST_HEAD(&(cwmp->head_session_queue));
|
||||
if(error = global_conf_init(&(cwmp->conf)))
|
||||
|
|
|
|||
16
cwmp.c
16
cwmp.c
|
|
@ -455,11 +455,6 @@ struct session *cwmp_add_queue_session (struct cwmp *cwmp)
|
|||
|
||||
int run_session_end_func (struct session *session)
|
||||
{
|
||||
if (session->end_session & END_SESSION_NOTIFY)
|
||||
{
|
||||
CWMP_LOG (INFO,"notification value change: end session request");
|
||||
cwmp_add_notification();
|
||||
}
|
||||
|
||||
if (session->end_session & END_SESSION_EXTERNAL_ACTION)
|
||||
{
|
||||
|
|
@ -545,6 +540,7 @@ int main(int argc, char **argv)
|
|||
struct cwmp *cwmp = &cwmp_main;
|
||||
int error;
|
||||
pthread_t periodic_event_thread;
|
||||
pthread_t handle_notify_thread;
|
||||
pthread_t scheduleInform_thread;
|
||||
pthread_t download_thread;
|
||||
pthread_t ubus_thread;
|
||||
|
|
@ -579,7 +575,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
CWMP_LOG(ERROR,"Error when creating the http connection request server thread!");
|
||||
}
|
||||
#if 0
|
||||
#if 1
|
||||
error = pthread_create(&ubus_thread, NULL, &thread_uloop_run, NULL);
|
||||
if (error<0)
|
||||
{
|
||||
|
|
@ -591,6 +587,11 @@ int main(int argc, char **argv)
|
|||
{
|
||||
CWMP_LOG(ERROR,"Error error when creating the periodic event thread!");
|
||||
}
|
||||
error = pthread_create(&handle_notify_thread, NULL, &thread_handle_notify, (void *)cwmp);
|
||||
if (error<0)
|
||||
{
|
||||
CWMP_LOG(ERROR,"Error error when creating the handle notify thread!");
|
||||
}
|
||||
error = pthread_create(&scheduleInform_thread, NULL, &thread_cwmp_rpc_cpe_scheduleInform, (void *)cwmp);
|
||||
if (error<0)
|
||||
{
|
||||
|
|
@ -603,10 +604,11 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
cwmp_schedule_session(cwmp);
|
||||
#if 0
|
||||
#if 1
|
||||
pthread_join(ubus_thread, NULL);
|
||||
#endif
|
||||
pthread_join(periodic_event_thread, NULL);
|
||||
pthread_join(handle_notify_thread, NULL);
|
||||
pthread_join(scheduleInform_thread, NULL);
|
||||
pthread_join(download_thread, NULL);
|
||||
pthread_join(http_cr_server_thread, NULL);
|
||||
|
|
|
|||
38
event.c
38
event.c
|
|
@ -162,12 +162,18 @@ void cwmp_add_notification(void)
|
|||
struct cwmp *cwmp = &cwmp_main;
|
||||
struct dm_enabled_notify *p;
|
||||
struct dm_parameter *dm_parameter;
|
||||
struct dmctx dmctx = {0};
|
||||
int fault;
|
||||
bool isactive = false;
|
||||
|
||||
pthread_mutex_lock(&(cwmp->mutex_session_send));
|
||||
pthread_mutex_lock(&(cwmp->mutex_handle_notify));
|
||||
cwmp->count_handle_notify = 0;
|
||||
pthread_mutex_unlock(&(cwmp->mutex_handle_notify));
|
||||
|
||||
dm_ctx_init(&dmctx);
|
||||
list_for_each_entry(p, &list_enabled_notify, list) {
|
||||
struct dmctx dmctx = {0};
|
||||
dm_ctx_init(&dmctx);
|
||||
dm_ctx_init_sub(&dmctx);
|
||||
fault = dm_entry_param_method(&dmctx, CMD_GET_VALUE, p->name, NULL, NULL);
|
||||
if (!fault && dmctx.list_parameter.next != &dmctx.list_parameter) {
|
||||
dm_parameter = list_entry(dmctx.list_parameter.next, struct dm_parameter, list);
|
||||
|
|
@ -178,23 +184,24 @@ void cwmp_add_notification(void)
|
|||
isactive = true;
|
||||
}
|
||||
}
|
||||
dm_ctx_clean(&dmctx);
|
||||
dm_ctx_clean_sub(&dmctx);
|
||||
}
|
||||
pthread_mutex_lock (&(cwmp->mutex_session_queue));
|
||||
dm_ctx_clean(&dmctx);
|
||||
pthread_mutex_unlock(&(cwmp->mutex_session_send));
|
||||
if (isactive)
|
||||
{
|
||||
pthread_mutex_lock(&(cwmp->mutex_session_queue));
|
||||
event_container = cwmp_add_event_container(cwmp, EVENT_IDX_4VALUE_CHANGE, "");
|
||||
if (event_container == NULL)
|
||||
{
|
||||
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
|
||||
pthread_mutex_unlock(&(cwmp->mutex_session_queue));
|
||||
return;
|
||||
}
|
||||
cwmp_save_event_container(cwmp,event_container);
|
||||
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
|
||||
pthread_mutex_unlock(&(cwmp->mutex_session_queue));
|
||||
pthread_cond_signal(&(cwmp->threshold_session_send));
|
||||
return;
|
||||
}
|
||||
pthread_mutex_unlock (&(cwmp->mutex_session_queue));
|
||||
}
|
||||
|
||||
int cwmp_root_cause_event_boot (struct cwmp *cwmp)
|
||||
|
|
@ -351,6 +358,23 @@ int cwmp_root_cause_getRPCMethod (struct cwmp *cwmp)
|
|||
return CWMP_OK;
|
||||
}
|
||||
|
||||
void *thread_handle_notify(void *v)
|
||||
{
|
||||
struct cwmp *cwmp = (struct cwmp *) v;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
pthread_mutex_lock(&(cwmp->mutex_handle_notify));
|
||||
pthread_cond_wait(&(cwmp->threshold_handle_notify), &(cwmp->mutex_handle_notify));
|
||||
pthread_mutex_unlock(&(cwmp->mutex_handle_notify));
|
||||
while(cwmp->count_handle_notify) {
|
||||
cwmp_add_notification();
|
||||
}
|
||||
|
||||
}
|
||||
return CWMP_OK;
|
||||
}
|
||||
|
||||
void *thread_event_periodic (void *v)
|
||||
{
|
||||
struct cwmp *cwmp = (struct cwmp *) v;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ enum end_session {
|
|||
END_SESSION_EXTERNAL_ACTION = 1<<1,
|
||||
END_SESSION_RELOAD = 1<<2,
|
||||
END_SESSION_FACTORY_RESET = 1<<3,
|
||||
END_SESSION_NOTIFY = 1<<4
|
||||
};
|
||||
|
||||
enum cwmp_start {
|
||||
|
|
@ -187,6 +186,9 @@ typedef struct cwmp {
|
|||
pthread_cond_t threshold_session_send;
|
||||
pthread_mutex_t mutex_periodic;
|
||||
pthread_cond_t threshold_periodic;
|
||||
pthread_mutex_t mutex_handle_notify;
|
||||
pthread_cond_t threshold_handle_notify;
|
||||
int count_handle_notify;
|
||||
int retry_count_session;
|
||||
struct list_head *head_event_container;
|
||||
int pid_file;
|
||||
|
|
@ -241,5 +243,7 @@ void *thread_exit_program (void *v);
|
|||
void connection_request_ip_value_change(struct cwmp *cwmp);
|
||||
void connection_request_port_value_change(struct cwmp *cwmp, int port);
|
||||
void add_dm_parameter_tolist(struct list_head *head, char *param_name, char *param_data, char *param_type);
|
||||
void cwmp_set_end_session (unsigned int end_session_flag);
|
||||
void *thread_handle_notify(void *v);
|
||||
|
||||
#endif /* _CWMP_H__ */
|
||||
|
|
|
|||
20
ubus.c
20
ubus.c
|
|
@ -39,22 +39,20 @@ cwmp_handle_notify(struct ubus_context *ctx, struct ubus_object *obj,
|
|||
struct ubus_request_data *req, const char *method,
|
||||
struct blob_attr *msg)
|
||||
{
|
||||
bool send_signal = false;
|
||||
CWMP_LOG(INFO, "triggered ubus notification");
|
||||
|
||||
blob_buf_init(&b, 0);
|
||||
|
||||
if (cwmp_main.session_status.last_status == SESSION_RUNNING) {
|
||||
cwmp_set_end_session(END_SESSION_NOTIFY);
|
||||
blobmsg_add_u32(&b, "status", 0);
|
||||
}
|
||||
else {
|
||||
pthread_mutex_lock(&(cwmp_main.mutex_session_queue));
|
||||
dm_global_init();
|
||||
cwmp_add_notification();
|
||||
pthread_mutex_unlock(&(cwmp_main.mutex_session_queue));
|
||||
blobmsg_add_u32(&b, "status", 0);
|
||||
}
|
||||
pthread_mutex_lock(&(cwmp_main.mutex_handle_notify));
|
||||
if (!cwmp_main.count_handle_notify)
|
||||
send_signal = true;
|
||||
cwmp_main.count_handle_notify++;
|
||||
pthread_mutex_unlock(&(cwmp_main.mutex_handle_notify));
|
||||
if (send_signal)
|
||||
pthread_cond_signal(&(cwmp_main.threshold_handle_notify));
|
||||
|
||||
blobmsg_add_u32(&b, "status", 1);
|
||||
ubus_send_reply(ctx, req, b.head);
|
||||
blob_buf_free(&b);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue