From 26afb01c8fc91574f086bac9bca8a3d6210d3394 Mon Sep 17 00:00:00 2001 From: Lassi Marttala Date: Mon, 12 Mar 2012 16:20:14 +0100 Subject: GDLT-4 Improve queue handling, allow for other messages while transferring a large file. Signed-off-by: Christian Muck --- src/system/dlt-system-log.c | 19 ++++++++++++++----- src/system/dlt-system.c | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/system/dlt-system-log.c b/src/system/dlt-system-log.c index 2d2ea9e..6bd438a 100644 --- a/src/system/dlt-system-log.c +++ b/src/system/dlt-system-log.c @@ -77,7 +77,7 @@ #define Z_CHUNK_SZ 1024*128 #define INOTIFY_SZ (sizeof(struct inotify_event)) -#define INOTIFY_LEN (INOTIFY_SZ + 1024) +#define INOTIFY_LEN (INOTIFY_SZ + 256) #define MAX_FILE_QUEUE 256 /* Check if the file name ends in .z */ @@ -203,8 +203,9 @@ void dlt_system_filetransfer_run(DltSystemOptions *options,DltSystemRuntime *run runtime->filetransferFile[0]=0; } - /* Check inotify watches */ - if(file_stack_ptr < MAX_FILE_QUEUE) + /* Check inotify watches, preserve space in the end of the stack. */ + /* Kinda kludgy for two directories. Consider using two queues? */ + if(file_stack_ptr < (MAX_FILE_QUEUE/2) - 4) { int len = read(dlt_system_inotify_handle, inotify_buf, INOTIFY_LEN); if(len < 0) @@ -334,6 +335,7 @@ void dlt_system_filetransfer_run(DltSystemOptions *options,DltSystemRuntime *run } if (runtime->filetransferRunning == 1) { + int iteration_package_count = 0; /* filetransfer is running, send next data */ while(runtime->filetransferLastSentPackagefiletransferCountPackages) { /* wait sending next package if more than 50% of buffer used */ @@ -343,6 +345,13 @@ void dlt_system_filetransfer_run(DltSystemOptions *options,DltSystemRuntime *run break; } + /* Give a chance for other packets to go through periodically */ + if(iteration_package_count > 100) + { + iteration_package_count = 0; + break; + } + runtime->filetransferLastSentPackage++; transferResult = dlt_user_log_file_data(context,runtime->filetransferFile,runtime->filetransferLastSentPackage,options->FiletransferTimeoutBetweenLogs); if(transferResult < 0) @@ -353,8 +362,8 @@ void dlt_system_filetransfer_run(DltSystemOptions *options,DltSystemRuntime *run runtime->filetransferRunning = 0; runtime->timeFiletransferDelay = options->FiletransferTimeDelay; return; - } - + } + iteration_package_count++; } if(runtime->filetransferLastSentPackage==runtime->filetransferCountPackages) { transferResult = dlt_user_log_file_end(context,runtime->filetransferFile,0); diff --git a/src/system/dlt-system.c b/src/system/dlt-system.c index 13bc0bc..13be32d 100755 --- a/src/system/dlt-system.c +++ b/src/system/dlt-system.c @@ -640,7 +640,7 @@ int main(int argc, char* argv[]) { if(dlt_system_filetransfer_init(&options,&runtime) < 0) { - dprintf("Error initializing filetransfer:\n%s", strerror(errno)); + fprintf(stderr, "Error initializing filetransfer:\n%s\n", strerror(errno)); return -1; } } -- cgit v1.2.1