From 1a372e360e2333c6b958090efb31926189fe1586 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Sat, 27 Feb 2016 11:51:36 +0100 Subject: [PATCH] read/write logs with file open as binary --- coreapi/linphonecore.c | 11 ++++++----- tester/log_collection_tester.c | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index cb266123d..9fbffa060 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -609,12 +609,12 @@ static int prepare_log_collection_file_to_upload(const char *filename) { ortp_mutex_lock(&liblinphone_log_collection_mutex); output_filename = ms_strdup_printf("%s/%s", liblinphone_log_collection_path ? liblinphone_log_collection_path : LOG_COLLECTION_DEFAULT_PATH, filename); - output_file = COMPRESS_OPEN(output_filename, "w"); + output_file = COMPRESS_OPEN(output_filename, "wb"); if (output_file == NULL) goto error; input_filename = ms_strdup_printf("%s/%s1.log", liblinphone_log_collection_path ? liblinphone_log_collection_path : LOG_COLLECTION_DEFAULT_PATH, liblinphone_log_collection_prefix ? liblinphone_log_collection_prefix : LOG_COLLECTION_DEFAULT_PREFIX); - input_file = fopen(input_filename, "r"); + input_file = fopen(input_filename, "rb"); if (input_file == NULL) goto error; ret = compress_file(input_file, output_file); if (ret <= 0) goto error; @@ -623,7 +623,7 @@ static int prepare_log_collection_file_to_upload(const char *filename) { input_filename = ms_strdup_printf("%s/%s2.log", liblinphone_log_collection_path ? liblinphone_log_collection_path : LOG_COLLECTION_DEFAULT_PATH, liblinphone_log_collection_prefix ? liblinphone_log_collection_prefix : LOG_COLLECTION_DEFAULT_PREFIX); - input_file = fopen(input_filename, "r"); + input_file = fopen(input_filename, "rb"); if (input_file != NULL) { ret = compress_file(input_file, output_file); if (ret <= 0) goto error; @@ -671,9 +671,10 @@ void linphone_core_upload_log_collection(LinphoneCore *core) { COMPRESSED_LOG_COLLECTION_EXTENSION); linphone_content_set_name(core->log_collection_upload_information, name); if (prepare_log_collection_file_to_upload(name) <= 0) { - linphone_content_unref(core->log_collection_upload_information); + linphone_content_unref(core->log_collection_upload_information); core->log_collection_upload_information = NULL; - return; + ms_error("prepare_log_collection_file_to_upload(): error."); + return; } linphone_content_set_size(core->log_collection_upload_information, get_size_of_file_to_upload(name)); uri = belle_generic_uri_parse(linphone_core_get_log_collection_upload_server_url(core)); diff --git a/tester/log_collection_tester.c b/tester/log_collection_tester.c index caf96fb31..1b394ccdb 100644 --- a/tester/log_collection_tester.c +++ b/tester/log_collection_tester.c @@ -301,17 +301,17 @@ static void upload_collected_traces(void) { linphone_core_set_log_collection_upload_server_url(marie->lc,"https://www.linphone.org:444/lft.php"); // Generate some logs while (--waiting) ms_error("(test error)Waiting %d...", waiting); - linphone_core_compress_log_collection(); + ms_free(linphone_core_compress_log_collection()); linphone_core_upload_log_collection(marie->lc); - BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphoneCoreLogCollectionUploadStateDelivered,1)); + BC_ASSERT_TRUE(wait_for_until(marie->lc,marie->lc,&marie->stat.number_of_LinphoneCoreLogCollectionUploadStateDelivered,1, 10000)); /*try 2 times*/ waiting=100; linphone_core_reset_log_collection(); while (--waiting) ms_error("(test error)Waiting %d...", waiting); - linphone_core_compress_log_collection(); + ms_free(linphone_core_compress_log_collection()); linphone_core_upload_log_collection(marie->lc); - BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphoneCoreLogCollectionUploadStateDelivered,2)); + BC_ASSERT_TRUE(wait_for_until(marie->lc,marie->lc,&marie->stat.number_of_LinphoneCoreLogCollectionUploadStateDelivered,2, 10000)); collect_cleanup(marie); } }