Make daemon buffer size configurable
authorAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Tue, 13 May 2014 09:09:59 +0000 (11:09 +0200)
committerAlexander Wenzel <Alexander.AW.Wenzel@bmw.de>
Fri, 16 May 2014 06:37:34 +0000 (08:37 +0200)
Signed-off-by: Alexander Wenzel <Alexander.AW.Wenzel@bmw.de>
src/daemon/dlt-daemon.c
src/daemon/dlt-daemon.h
src/daemon/dlt.conf
src/daemon/dlt_daemon_common.c
src/daemon/dlt_daemon_common.h

index 5f7d0dd..c8b4703 100644 (file)
@@ -178,6 +178,9 @@ int option_file_parser(DltDaemonLocal *daemon_local)
        strncpy(daemon_local->flags.loggingFilename, DLT_USER_DIR "/dlt.log",sizeof(daemon_local->flags.loggingFilename)-1);
        daemon_local->flags.loggingFilename[sizeof(daemon_local->flags.loggingFilename)-1]=0;
        daemon_local->timeoutOnSend = 4;
+       daemon_local->RingbufferMinSize = DLT_DAEMON_RINGBUFFER_MIN_SIZE;
+       daemon_local->RingbufferMaxSize = DLT_DAEMON_RINGBUFFER_MAX_SIZE;
+       daemon_local->RingbufferStepSize = DLT_DAEMON_RINGBUFFER_STEP_SIZE;
        daemon_local->flags.sendECUSoftwareVersion = 0;
        memset(daemon_local->flags.pathToECUSoftwareVersion, 0, sizeof(daemon_local->flags.pathToECUSoftwareVersion));
        daemon_local->flags.sendTimezone = 0;
@@ -314,6 +317,18 @@ int option_file_parser(DltDaemonLocal *daemon_local)
                                                        daemon_local->timeoutOnSend = atoi(value);
                                                        //printf("Option: %s=%s\n",token,value);
                                                }
+                               else if(strcmp(token,"RingbufferMinSize")==0)
+                                               {
+                                                       sscanf(value,"%lu",&(daemon_local->RingbufferMinSize));
+                                               }
+                               else if(strcmp(token,"RingbufferMaxSize")==0)
+                                               {
+                                                       sscanf(value,"%lu",&(daemon_local->RingbufferMaxSize));
+                                               }
+                               else if(strcmp(token,"RingbufferStepSize")==0)
+                                               {
+                                                       sscanf(value,"%lu",&(daemon_local->RingbufferStepSize));
+                                               }
                                                else if(strcmp(token,"SharedMemorySize")==0)
                                                {
                                                        daemon_local->flags.sharedMemorySize = atoi(value);
@@ -686,7 +701,7 @@ int dlt_daemon_local_init_p2(DltDaemon *daemon, DltDaemonLocal *daemon_local, in
     }
 
     /* Daemon data */
-    if (dlt_daemon_init(daemon,daemon_local->flags.ivalue,daemon_local->flags.vflag)==-1)
+    if (dlt_daemon_init(daemon,daemon_local->RingbufferMinSize,daemon_local->RingbufferMaxSize,daemon_local->RingbufferStepSize,daemon_local->flags.ivalue,daemon_local->flags.vflag)==-1)
     {
        dlt_log(LOG_ERR,"Could not initialize daemon data\n");
                return -1;
index 69c679e..dfe4de3 100755 (executable)
@@ -136,6 +136,9 @@ typedef struct
     int timer_wd;                        /** file descriptor for watchdog timer */\r
 #endif\r
     int timeoutOnSend;\r
+    unsigned long RingbufferMinSize;\r
+    unsigned long RingbufferMaxSize;\r
+    unsigned long RingbufferStepSize;\r
     int timer_one_s;\r
     int timer_sixty_s;\r
 } DltDaemonLocal;\r
index a079d3e..1032a9a 100644 (file)
@@ -44,6 +44,15 @@ LoggingFilename = /tmp/dlt.log
 # Timeout on send to client (sec)                                                                                      
 TimeOutOnSend = 4
 
+# The minimum size of the Ringbuffer, used for storing temporary DLT messages, until client is connected (Default: 500000)
+RingbufferMinSize = 500000
+
+# The max size of the Ringbuffer, used for storing temporary DLT messages, until client is connected (Default: 10000000)
+RingbufferMaxSize = 10000000
+
+# The step size the Ringbuffer is increased, used for storing temporary DLT messages, until client is connected (Default: 500000)
+RingbufferStepSize = 500000
+
 ########################################################################
 # Offline Trace memory                                                 #
 ########################################################################
index 6e9bf9b..a2392fc 100644 (file)
@@ -120,7 +120,7 @@ static int dlt_daemon_cmp_apid_ctid(const void *m1, const void *m2)
     return ret;
 }
 
-int dlt_daemon_init(DltDaemon *daemon,const char *runtime_directory, int verbose)
+int dlt_daemon_init(DltDaemon *daemon,unsigned long RingbufferMinSize,unsigned long RingbufferMaxSize,unsigned long RingbufferStepSize,const char *runtime_directory, int verbose)
 {
     PRINT_FUNCTION_VERBOSE(verbose);
 
@@ -206,7 +206,9 @@ int dlt_daemon_init(DltDaemon *daemon,const char *runtime_directory, int verbose
     dlt_set_id(daemon->ecuid,"");
 
     /* initialize ring buffer for client connection */
-    if (dlt_buffer_init_dynamic(&(daemon->client_ringbuffer), DLT_DAEMON_RINGBUFFER_MIN_SIZE,DLT_DAEMON_RINGBUFFER_MAX_SIZE,DLT_DAEMON_RINGBUFFER_STEP_SIZE)==-1)
+    snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE,"Ringbuffer configuration: %lu/%lu/%lu\n", RingbufferMinSize,RingbufferMaxSize,RingbufferStepSize );
+    dlt_log(LOG_INFO, str);
+    if (dlt_buffer_init_dynamic(&(daemon->client_ringbuffer), RingbufferMinSize,RingbufferMaxSize,RingbufferStepSize)==-1)
     {
        return -1;
     }
index 4c92c43..db1bc0b 100644 (file)
@@ -163,11 +163,14 @@ typedef struct
  * Initialise the dlt daemon structure\r
  * This function must be called before using further dlt daemon structure\r
  * @param daemon pointer to dlt daemon structure\r
+ * @param RingbufferMinSize ringbuffer size\r
+ * @param RingbufferMaxSize ringbuffer size\r
+ * @param RingbufferStepSize ringbuffer size\r
  * @param runtime_directory Directory of persistent configuration\r
  * @param verbose if set to true verbose information is printed out.\r
  * @return negative value if there was an error\r
  */\r
-int dlt_daemon_init(DltDaemon *daemon,const char *runtime_directory,int verbose);\r
+int dlt_daemon_init(DltDaemon *daemon,unsigned long RingbufferMinSize,unsigned long RingbufferMaxSize,unsigned long RingbufferStepSize,const char *runtime_directory,int verbose);\r
 /**\r
  * De-Initialise the dlt daemon structure\r
  * @param daemon pointer to dlt daemon structure\r