diff options
author | Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> | 2011-11-15 00:14:39 +0100 |
---|---|---|
committer | Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> | 2011-11-15 00:14:39 +0100 |
commit | c870bcb94957fcbab7f56b6cd3ff5a0fc659f24c (patch) | |
tree | 93b273d227bb3921cb255217bf5b0325b44d3a34 /src/daemon | |
parent | c74050b028d91c9bb8995dafba440babc7b621ff (diff) | |
download | DLT-daemon-c870bcb94957fcbab7f56b6cd3ff5a0fc659f24c.tar.gz |
Added dynamic increasable ringbuffers to user lib and daemon.
Diffstat (limited to 'src/daemon')
-rwxr-xr-x | src/daemon/dlt-daemon.c | 11 | ||||
-rwxr-xr-x | src/daemon/dlt_daemon_common.c | 7 | ||||
-rwxr-xr-x | src/daemon/dlt_daemon_common.h | 6 |
3 files changed, 15 insertions, 9 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index f2ba0cb..dd18d4b 100755 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -1171,7 +1171,7 @@ int dlt_daemon_process_user_messages(DltDaemon *daemon, DltDaemonLocal *daemon_l } /* read data from FIFO */ - if (dlt_receiver_receive_fd(&(daemon_local->receiver))<=0) + if (dlt_receiver_receive_fd(&(daemon_local->receiver))<0) { dlt_log(LOG_ERR, "dlt_receiver_receive_fd() for user messages failed!\n"); return -1; @@ -1855,7 +1855,7 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon, DltDaemonLocal *daemo /* Message was not sent to client, so store it in client ringbuffer */ if (sent==0) { - if (dlt_ringbuffer_put3(&(daemon->client_ringbuffer), + if (dlt_buffer_push3(&(daemon->client_ringbuffer), daemon_local->msg.headerbuffer+sizeof(DltStorageHeader),daemon_local->msg.headersize-sizeof(DltStorageHeader), daemon_local->msg.databuffer,daemon_local->msg.datasize, 0, 0 @@ -2182,8 +2182,8 @@ int dlt_daemon_process_user_message_log_mode(DltDaemon *daemon, DltDaemonLocal * int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose) { - static uint8_t data[DLT_DAEMON_RINGBUFFER_SIZE]; - size_t length=0; + static uint8_t data[DLT_DAEMON_RCVBUFSIZE]; + int length; int j, third_value; ssize_t ret; @@ -2196,7 +2196,7 @@ int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daem } /* Attention: If the message can't be send at this time, it will be silently discarded. */ - while ((dlt_ringbuffer_get(&(daemon->client_ringbuffer), data, &length ))!=-1) + while ((length = dlt_buffer_pull(&(daemon->client_ringbuffer), data, sizeof(data) )) > 0) { /* look if TCP connection to client is available */ for (j = 0; j <= daemon_local->fdmax; j++) @@ -2241,6 +2241,7 @@ int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daem } } /* if */ } /* for */ + length = sizeof(data); } return 0; diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c index aaed7a2..1de6aea 100755 --- a/src/daemon/dlt_daemon_common.c +++ b/src/daemon/dlt_daemon_common.c @@ -188,7 +188,7 @@ 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_ringbuffer_init(&(daemon->client_ringbuffer), DLT_DAEMON_RINGBUFFER_SIZE)==-1) + if (dlt_buffer_init_dynamic(&(daemon->client_ringbuffer), DLT_DAEMON_RINGBUFFER_MIN_SIZE,DLT_DAEMON_RINGBUFFER_MAX_SIZE,DLT_DAEMON_RINGBUFFER_STEP_SIZE)==-1) { return -1; } @@ -217,6 +217,9 @@ int dlt_daemon_free(DltDaemon *daemon,int verbose) return -1; } + /* free ringbuffer */ + dlt_buffer_free_dynamic(&(daemon->client_ringbuffer)); + return 0; } @@ -2145,7 +2148,7 @@ void dlt_daemon_control_send_control_message( int sock, DltDaemon *daemon, DltMe else { /* Store message in history buffer */ - if (dlt_ringbuffer_put3(&(daemon->client_ringbuffer), + if (dlt_buffer_push3(&(daemon->client_ringbuffer), msg->headerbuffer+sizeof(DltStorageHeader),msg->headersize-sizeof(DltStorageHeader), msg->databuffer,msg->datasize, 0, 0 diff --git a/src/daemon/dlt_daemon_common.h b/src/daemon/dlt_daemon_common.h index 17bc32f..1870295 100755 --- a/src/daemon/dlt_daemon_common.h +++ b/src/daemon/dlt_daemon_common.h @@ -96,7 +96,9 @@ extern "C" {
#endif
-#define DLT_DAEMON_RINGBUFFER_SIZE 100000 /**< Ring buffer size for storing log messages while no client is connected */
+#define DLT_DAEMON_RINGBUFFER_MIN_SIZE 100000 /**< Ring buffer size for storing log messages while no client is connected */
+#define DLT_DAEMON_RINGBUFFER_MAX_SIZE 500000 /**< Ring buffer size for storing log messages while no client is connected */
+#define DLT_DAEMON_RINGBUFFER_STEP_SIZE 100000 /**< Ring buffer size for storing log messages while no client is connected */
#define DLT_DAEMON_STORE_TO_BUFFER -2 /**< Constant value to identify the command "store to buffer" */
@@ -149,7 +151,7 @@ typedef struct char ecuid[DLT_ID_SIZE]; /**< ECU ID of daemon */
int sendserialheader; /**< 1: send serial header; 0 don't send serial header */
int timingpackets; /**< 1: send continous timing packets; 0 don't send continous timing packets */
- DltRingBuffer client_ringbuffer; /**< Ring-buffer for storing received logs while no client connection is available */
+ DltBuffer client_ringbuffer; /**< Ring-buffer for storing received logs while no client connection is available */
char runtime_application_cfg[256]; /**< Path and filename of persistent application configuration */
char runtime_context_cfg[256]; /**< Path and filename of persistent context configuration */
char runtime_configuration[256]; /**< Path and filename of persistent configuration */
|