Commit fb843989 authored by winckel's avatar winckel

Modified ITTI to not transmit message for "TASK_UNKNOWN", this allow using...

Modified ITTI to not transmit message for "TASK_UNKNOWN", this allow using message to this task for debug purpose.

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4362 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 113c5c37
...@@ -241,48 +241,50 @@ int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *me ...@@ -241,48 +241,50 @@ int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *me
priority = itti_get_message_priority (message_id); priority = itti_get_message_priority (message_id);
/* We cannot send a message if the task is not running */ /* Increment the global message number */
DevCheck(itti_desc.threads[thread_id].task_state == TASK_STATE_READY, itti_desc.threads[thread_id].task_state, message_number = itti_increment_message_number ();
TASK_STATE_READY, thread_id);
#if !defined(ENABLE_EVENT_FD) itti_dump_queue_message (message_number, message, itti_desc.messages_info[message_id].name,
/* Lock the mutex to get exclusive access to the list */ MESSAGE_SIZE(message_id));
pthread_mutex_lock (&itti_desc.tasks[task_id].message_queue_mutex);
/* Check the number of messages in the queue */ if (task_id != TASK_UNKNOWN)
DevCheck(itti_desc.tasks[task_id].message_in_queue < itti_desc.tasks_info[task_id].queue_size, {
task_id, itti_desc.tasks[task_id].message_in_queue, itti_desc.tasks_info[task_id].queue_size); /* We cannot send a message if the task is not running */
#endif DevCheck(itti_desc.threads[thread_id].task_state == TASK_STATE_READY, itti_desc.threads[thread_id].task_state,
TASK_STATE_READY, thread_id);
/* Allocate new list element */ #if !defined(ENABLE_EVENT_FD)
new = (struct message_list_s *) malloc (sizeof(struct message_list_s)); /* Lock the mutex to get exclusive access to the list */
DevAssert(new != NULL); pthread_mutex_lock (&itti_desc.tasks[task_id].message_queue_mutex);
/* Increment the global message number */ /* Check the number of messages in the queue */
message_number = itti_increment_message_number (); DevCheck(itti_desc.tasks[task_id].message_in_queue < itti_desc.tasks_info[task_id].queue_size,
task_id, itti_desc.tasks[task_id].message_in_queue, itti_desc.tasks_info[task_id].queue_size);
#endif
/* Fill in members */ /* Allocate new list element */
new->msg = message; new = (struct message_list_s *) malloc (sizeof(struct message_list_s));
new->message_number = message_number; DevAssert(new != NULL);
new->message_priority = priority;
itti_dump_queue_message (message_number, message, itti_desc.messages_info[message_id].name, /* Fill in members */
MESSAGE_SIZE(message_id)); new->msg = message;
new->message_number = message_number;
new->message_priority = priority;
#if defined(ENABLE_EVENT_FD) #if defined(ENABLE_EVENT_FD)
{ {
uint64_t sem_counter = 1; uint64_t sem_counter = 1;
lfds611_queue_enqueue(itti_desc.tasks[task_id].message_queue, new); lfds611_queue_enqueue(itti_desc.tasks[task_id].message_queue, new);
/* Call to write for an event fd must be of 8 bytes */ /* Call to write for an event fd must be of 8 bytes */
write(itti_desc.tasks[task_id].task_event_fd, &sem_counter, sizeof(sem_counter)); write(itti_desc.tasks[task_id].task_event_fd, &sem_counter, sizeof(sem_counter));
} }
#else #else
if (STAILQ_EMPTY (&itti_desc.tasks[task_id].message_queue)) { if (STAILQ_EMPTY (&itti_desc.tasks[task_id].message_queue)) {
STAILQ_INSERT_HEAD (&itti_desc.tasks[task_id].message_queue, new, next_element); STAILQ_INSERT_HEAD (&itti_desc.tasks[task_id].message_queue, new, next_element);
} }
else { else {
// struct message_list_s *insert_after = NULL; // struct message_list_s *insert_after = NULL;
// struct message_list_s *temp; // struct message_list_s *temp;
// //
...@@ -306,17 +308,18 @@ int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *me ...@@ -306,17 +308,18 @@ int itti_send_msg_to_task(task_id_t task_id, instance_t instance, MessageDef *me
// STAILQ_INSERT_AFTER(&itti_desc.tasks[task_id].message_queue, insert_after, new, // STAILQ_INSERT_AFTER(&itti_desc.tasks[task_id].message_queue, insert_after, new,
// next_element); // next_element);
// } // }
} }
/* Update the number of messages in the queue */ /* Update the number of messages in the queue */
itti_desc.tasks[task_id].message_in_queue++; itti_desc.tasks[task_id].message_in_queue++;
if (itti_desc.tasks[task_id].message_in_queue == 1) { if (itti_desc.tasks[task_id].message_in_queue == 1) {
/* Emit a signal to wake up target task thread */ /* Emit a signal to wake up target task thread */
pthread_cond_signal (&itti_desc.tasks[task_id].message_queue_cond_var); pthread_cond_signal (&itti_desc.tasks[task_id].message_queue_cond_var);
} }
/* Release the mutex */ /* Release the mutex */
pthread_mutex_unlock (&itti_desc.tasks[task_id].message_queue_mutex); pthread_mutex_unlock (&itti_desc.tasks[task_id].message_queue_mutex);
#endif #endif
}
ITTI_DEBUG( ITTI_DEBUG(
"Message %s, number %lu with priority %d successfully sent to queue (%u:%s)\n", "Message %s, number %lu with priority %d successfully sent to queue (%u:%s)\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment