GDLT-4 Limit maximum file queue to 256 files.
authorLassi Marttala <lassi.lm.marttala@partner.bmw.com>
Mon, 12 Mar 2012 12:49:30 +0000 (13:49 +0100)
committerChristian Muck <christian.muck@bmw.de>
Wed, 4 Apr 2012 12:29:27 +0000 (14:29 +0200)
Signed-off-by: Christian Muck <christian.muck@bmw.de>
src/system/dlt-system-log.c

index 61ec161..2d2ea9e 100644 (file)
@@ -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 */