From c8fa1f955339e3e63fdfa374b0cfb9490fdcf2ec Mon Sep 17 00:00:00 2001 From: winckel <winckel@eurecom.fr> Date: Wed, 4 Dec 2013 17:04:36 +0000 Subject: [PATCH] Added detection and skip of incomplete message at end of file when reading a message file. git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4597 818b1a75-f10b-46b9-bf7c-635c3b92a50f --- .../itti_analyzer/libui/ui_notifications.c | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/common/utils/itti_analyzer/libui/ui_notifications.c b/common/utils/itti_analyzer/libui/ui_notifications.c index a63b9a4f0b..f775afbd85 100644 --- a/common/utils/itti_analyzer/libui/ui_notifications.c +++ b/common/utils/itti_analyzer/libui/ui_notifications.c @@ -132,7 +132,16 @@ int ui_messages_read(char *filename) break; } - if (read_data > 0) + if (read_data == 0) + { + break; + } + + if (read_data < sizeof(itti_socket_header_t)) + { + g_warning("Failed to read a complete message header from file \"%s\": %s", filename, g_strerror (errno)); + } + else { read_fraction += (double) read_data / size; @@ -145,12 +154,10 @@ int ui_messages_read(char *filename) { input_data = malloc (input_data_length); - if (read (source, input_data, input_data_length) < 0) + read_data = read (source, input_data, input_data_length); + if (read_data < input_data_length) { - g_warning("Failed to read from file \"%s\": %s", filename, g_strerror (errno)); - ui_notification_dialog (GTK_MESSAGE_ERROR, "open messages", - "Failed to read from file \"%s\": %s", filename, g_strerror (errno)); - result = RC_FAIL; + g_warning("Failed to read a complete message from file \"%s\": %s", filename, g_strerror (errno)); break; } @@ -231,8 +238,7 @@ int ui_messages_read(char *filename) ui_progress_bar_terminate (); - g_message( - "Read %d messages (%d to display) from file \"%s\"\n", read_messages, ui_tree_view_get_filtered_number(), filename); + g_message("Read %d messages (%d to display) from file \"%s\"\n", read_messages, ui_tree_view_get_filtered_number(), filename); close (source); } -- GitLab