diff options
author | Lassi Marttala <lassi.lm.marttala@partner.bmw.com> | 2012-03-12 13:49:30 +0100 |
---|---|---|
committer | Christian Muck <christian.muck@bmw.de> | 2012-04-04 14:29:27 +0200 |
commit | b3a2d73607967004056917c3f3b91bd35e6beba6 (patch) | |
tree | 15524cca1ab1e14d9fa9143ba9ac1a9903b3a57f | |
parent | dfc7576ba36471f1da42b936aa8239aa6f423d36 (diff) | |
download | DLT-daemon-b3a2d73607967004056917c3f3b91bd35e6beba6.tar.gz |
GDLT-4 Limit maximum file queue to 256 files.
Signed-off-by: Christian Muck <christian.muck@bmw.de>
-rw-r--r-- | src/system/dlt-system-log.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/system/dlt-system-log.c b/src/system/dlt-system-log.c index 61ec161..2d2ea9e 100644 --- a/src/system/dlt-system-log.c +++ b/src/system/dlt-system-log.c @@ -78,6 +78,7 @@ #define INOTIFY_SZ (sizeof(struct inotify_event)) #define INOTIFY_LEN (INOTIFY_SZ + 1024) +#define MAX_FILE_QUEUE 256 /* Check if the file name ends in .z */ int dlt_system_is_gz_file(char *file_name) @@ -182,7 +183,7 @@ void dlt_system_filetransfer_run(DltSystemOptions *options,DltSystemRuntime *run int transferResult; int total_size, used_size; static char inotify_buf[INOTIFY_LEN]; - static char file_stack[256][256]; + static char file_stack[256][MAX_FILE_QUEUE]; static int file_stack_ptr = -1; if(runtime->filetransferRunning == 0) { @@ -203,26 +204,29 @@ void dlt_system_filetransfer_run(DltSystemOptions *options,DltSystemRuntime *run } /* Check inotify watches */ - int len = read(dlt_system_inotify_handle, inotify_buf, INOTIFY_LEN); - if(len < 0) + if(file_stack_ptr < MAX_FILE_QUEUE) { - if(errno != EWOULDBLOCK) { - fprintf(stderr, "dlt_system_filetransfer_run:\n%s\n", strerror(errno)); - return; + int len = read(dlt_system_inotify_handle, inotify_buf, INOTIFY_LEN); + if(len < 0) + { + if(errno != EWOULDBLOCK) { + fprintf(stderr, "dlt_system_filetransfer_run:\n%s\n", strerror(errno)); + return; + } } - } - int i = 0; - while(i < len) - { - struct inotify_event *event = (struct inotify_event *) &inotify_buf[i]; - printf("inotify: %s \n", event->name); - if(event->mask | IN_CLOSE_WRITE && event->mask | IN_MOVED_TO) + int i = 0; + while(i < len) { - file_stack_ptr++; - strcpy(file_stack[file_stack_ptr], event->name); + struct inotify_event *event = (struct inotify_event *) &inotify_buf[i]; + printf("inotify: %s \n", event->name); + if(event->mask | IN_CLOSE_WRITE && event->mask | IN_MOVED_TO) + { + file_stack_ptr++; + strcpy(file_stack[file_stack_ptr], event->name); + } + i += INOTIFY_SZ + event->len; } - i += INOTIFY_SZ + event->len; } /* filetransfer not running, check directory */ |