- Fix EFD_SEMAPHORE build issues
git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4642 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
@@ -83,7 +83,7 @@ const int itti_debug_poll = 0;
|
|||||||
/* Global message size */
|
/* Global message size */
|
||||||
#define MESSAGE_SIZE(mESSAGEiD) (sizeof(MessageHeader) + itti_desc.messages_info[mESSAGEiD].size)
|
#define MESSAGE_SIZE(mESSAGEiD) (sizeof(MessageHeader) + itti_desc.messages_info[mESSAGEiD].size)
|
||||||
|
|
||||||
#if !defined(EFD_SEMAPHORE)
|
#ifndef EFD_SEMAPHORE
|
||||||
# define KERNEL_VERSION_PRE_2_6_30 1
|
# define KERNEL_VERSION_PRE_2_6_30 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ typedef struct thread_desc_s {
|
|||||||
uint16_t nb_events;
|
uint16_t nb_events;
|
||||||
|
|
||||||
#if defined(KERNEL_VERSION_PRE_2_6_30)
|
#if defined(KERNEL_VERSION_PRE_2_6_30)
|
||||||
uint64_t sem_counter;
|
eventfd_t sem_counter;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Array of events monitored by the task.
|
/* Array of events monitored by the task.
|
||||||
@@ -392,7 +392,7 @@ int itti_send_msg_to_task(task_id_t destination_task_id, instance_t instance, Me
|
|||||||
if (TASK_GET_PARENT_TASK_ID(destination_task_id) == TASK_UNKNOWN)
|
if (TASK_GET_PARENT_TASK_ID(destination_task_id) == TASK_UNKNOWN)
|
||||||
{
|
{
|
||||||
ssize_t write_ret;
|
ssize_t write_ret;
|
||||||
uint64_t sem_counter = 1;
|
eventfd_t sem_counter = 1;
|
||||||
|
|
||||||
/* 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_ret = write (itti_desc.threads[destination_thread_id].task_event_fd, &sem_counter, sizeof(sem_counter));
|
write_ret = write (itti_desc.threads[destination_thread_id].task_event_fd, &sem_counter, sizeof(sem_counter));
|
||||||
@@ -534,8 +534,8 @@ static inline void itti_receive_msg_internal_event_fd(task_id_t task_id, uint8_t
|
|||||||
(itti_desc.threads[thread_id].events[i].data.fd == itti_desc.threads[thread_id].task_event_fd))
|
(itti_desc.threads[thread_id].events[i].data.fd == itti_desc.threads[thread_id].task_event_fd))
|
||||||
{
|
{
|
||||||
struct message_list_s *message = NULL;
|
struct message_list_s *message = NULL;
|
||||||
uint64_t sem_counter;
|
eventfd_t sem_counter;
|
||||||
ssize_t read_ret;
|
ssize_t read_ret;
|
||||||
|
|
||||||
/* Read will always return 1 */
|
/* Read will always return 1 */
|
||||||
read_ret = read (itti_desc.threads[thread_id].task_event_fd, &sem_counter, sizeof(sem_counter));
|
read_ret = read (itti_desc.threads[thread_id].task_event_fd, &sem_counter, sizeof(sem_counter));
|
||||||
@@ -543,7 +543,7 @@ static inline void itti_receive_msg_internal_event_fd(task_id_t task_id, uint8_t
|
|||||||
|
|
||||||
#if defined(KERNEL_VERSION_PRE_2_6_30)
|
#if defined(KERNEL_VERSION_PRE_2_6_30)
|
||||||
/* Store the value of the semaphore counter */
|
/* Store the value of the semaphore counter */
|
||||||
itti_desc.tasks[task_id].sem_counter = sem_counter - 1;
|
itti_desc.threads[task_id].sem_counter = sem_counter - 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (lfds611_queue_dequeue (itti_desc.tasks[task_id].message_queue, (void **) &message) == 0) {
|
if (lfds611_queue_dequeue (itti_desc.tasks[task_id].message_queue, (void **) &message) == 0) {
|
||||||
@@ -567,16 +567,18 @@ void itti_receive_msg(task_id_t task_id, MessageDef **received_msg)
|
|||||||
|
|
||||||
#if defined(KERNEL_VERSION_PRE_2_6_30)
|
#if defined(KERNEL_VERSION_PRE_2_6_30)
|
||||||
/* Store the value of the semaphore counter */
|
/* Store the value of the semaphore counter */
|
||||||
if (itti_desc.tasks[task_id].sem_counter > 0) {
|
if (itti_desc.threads[task_id].sem_counter > 0) {
|
||||||
|
struct message_list_s *message = NULL;
|
||||||
|
|
||||||
if (lfds611_queue_dequeue (itti_desc.tasks[task_id].message_queue, (void **) &message) == 0) {
|
if (lfds611_queue_dequeue (itti_desc.tasks[task_id].message_queue, (void **) &message) == 0) {
|
||||||
/* No element in list -> this should not happen */
|
/* No element in list -> this should not happen */
|
||||||
DevParam(task_id, itti_desc.tasks[task_id].sem_counter, 0);
|
DevParam(task_id, itti_desc.threads[task_id].sem_counter, 0);
|
||||||
}
|
}
|
||||||
DevAssert(message != NULL);
|
DevAssert(message != NULL);
|
||||||
*received_msg = message->msg;
|
*received_msg = message->msg;
|
||||||
free (message);
|
free (message);
|
||||||
|
|
||||||
itti_desc.tasks[task_id].sem_counter--;
|
itti_desc.threads[task_id].sem_counter--;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
itti_receive_msg_internal_event_fd(task_id, 0, received_msg);
|
itti_receive_msg_internal_event_fd(task_id, 0, received_msg);
|
||||||
@@ -720,7 +722,7 @@ static void *itti_rt_relay_thread(void *arg)
|
|||||||
if (pending_messages > 0)
|
if (pending_messages > 0)
|
||||||
{
|
{
|
||||||
ssize_t write_ret;
|
ssize_t write_ret;
|
||||||
uint64_t sem_counter = pending_messages;
|
eventfd_t sem_counter = pending_messages;
|
||||||
|
|
||||||
/* 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_ret = write (itti_desc.threads[thread_id].task_event_fd, &sem_counter, sizeof(sem_counter));
|
write_ret = write (itti_desc.threads[thread_id].task_event_fd, &sem_counter, sizeof(sem_counter));
|
||||||
|
|||||||
@@ -78,6 +78,10 @@ static const int itti_dump_debug = 0;
|
|||||||
while(0)
|
while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef EFD_SEMAPHORE
|
||||||
|
# define KERNEL_VERSION_PRE_2_6_30 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Message sent is an intertask dump type */
|
/* Message sent is an intertask dump type */
|
||||||
#define ITTI_DUMP_MESSAGE_TYPE 0x1
|
#define ITTI_DUMP_MESSAGE_TYPE 0x1
|
||||||
#define ITTI_STATISTIC_MESSAGE_TYPE 0x2
|
#define ITTI_STATISTIC_MESSAGE_TYPE 0x2
|
||||||
@@ -146,7 +150,7 @@ typedef struct {
|
|||||||
} itti_statistic_message_t;
|
} itti_statistic_message_t;
|
||||||
|
|
||||||
static itti_desc_t itti_dump_queue;
|
static itti_desc_t itti_dump_queue;
|
||||||
static FILE *dump_file;
|
static FILE *dump_file = NULL;
|
||||||
static int itti_dump_running = 1;
|
static int itti_dump_running = 1;
|
||||||
|
|
||||||
static int itti_dump_send_message(int sd, itti_dump_queue_item_t *message);
|
static int itti_dump_send_message(int sd, itti_dump_queue_item_t *message);
|
||||||
@@ -283,8 +287,8 @@ static int itti_dump_enqueue_message(itti_dump_queue_item_t *new, uint32_t messa
|
|||||||
__sync_fetch_and_add (&itti_dump_queue.messages_in_queue, 1);
|
__sync_fetch_and_add (&itti_dump_queue.messages_in_queue, 1);
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
ssize_t write_ret;
|
ssize_t write_ret;
|
||||||
uint64_t sem_counter = 1;
|
eventfd_t sem_counter = 1;
|
||||||
|
|
||||||
/* 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_ret = write(itti_dump_queue.event_fd, &sem_counter, sizeof(sem_counter));
|
write_ret = write(itti_dump_queue.event_fd, &sem_counter, sizeof(sem_counter));
|
||||||
@@ -523,19 +527,21 @@ static void *itti_dump_socket(void *arg_p)
|
|||||||
#ifndef RTAI
|
#ifndef RTAI
|
||||||
if (i == itti_dump_queue.event_fd) {
|
if (i == itti_dump_queue.event_fd) {
|
||||||
/* Notification of new element to dump from other tasks */
|
/* Notification of new element to dump from other tasks */
|
||||||
uint64_t sem_counter;
|
eventfd_t sem_counter;
|
||||||
ssize_t read_ret;
|
ssize_t read_ret;
|
||||||
|
|
||||||
/* Read will always return 1 */
|
/* Read will always return 1 for kernel versions > 2.6.30 */
|
||||||
read_ret = read (itti_dump_queue.event_fd, &sem_counter, sizeof(sem_counter));
|
read_ret = read (itti_dump_queue.event_fd, &sem_counter, sizeof(sem_counter));
|
||||||
if (read_ret < 0) {
|
if (read_ret < 0) {
|
||||||
ITTI_DUMP_ERROR("Failed read for semaphore: %s\n", strerror(errno));
|
ITTI_DUMP_ERROR("Failed read for semaphore: %s\n", strerror(errno));
|
||||||
pthread_exit(NULL);
|
pthread_exit(NULL);
|
||||||
}
|
}
|
||||||
DevCheck(read_ret == sizeof(sem_counter), read_ret, sizeof(sem_counter), 0);
|
DevCheck(read_ret == sizeof(sem_counter), read_ret, sizeof(sem_counter), 0);
|
||||||
|
#if defined(KERNEL_VERSION_PRE_2_6_30)
|
||||||
|
itti_dump_flush_ring_buffer(1);
|
||||||
|
#else
|
||||||
itti_dump_flush_ring_buffer(0);
|
itti_dump_flush_ring_buffer(0);
|
||||||
|
#endif
|
||||||
ITTI_DUMP_DEBUG("Write element to file\n");
|
ITTI_DUMP_DEBUG("Write element to file\n");
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
@@ -705,7 +711,11 @@ int itti_dump_init(const char * const messages_definition_xml, const char * cons
|
|||||||
#ifdef RTAI
|
#ifdef RTAI
|
||||||
itti_dump_queue.messages_in_queue = 0;
|
itti_dump_queue.messages_in_queue = 0;
|
||||||
#else
|
#else
|
||||||
|
# if defined(KERNEL_VERSION_PRE_2_6_30)
|
||||||
|
itti_dump_queue.event_fd = eventfd(0, 0);
|
||||||
|
# else
|
||||||
itti_dump_queue.event_fd = eventfd(0, EFD_SEMAPHORE);
|
itti_dump_queue.event_fd = eventfd(0, EFD_SEMAPHORE);
|
||||||
|
# endif
|
||||||
if (itti_dump_queue.event_fd == -1)
|
if (itti_dump_queue.event_fd == -1)
|
||||||
{
|
{
|
||||||
ITTI_DUMP_ERROR("eventfd failed: %s\n", strerror(errno));
|
ITTI_DUMP_ERROR("eventfd failed: %s\n", strerror(errno));
|
||||||
|
|||||||
Reference in New Issue
Block a user