summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Lipka <clipka@jp.adit-jv.com>2015-10-27 16:55:13 +0900
committerLutz Helwing <lutz_helwing@mentor.com>2015-11-24 09:48:42 +0100
commitbe6f37ba05e19ae9dab4e3414c5e6d8ae502ccf5 (patch)
tree06d8a1c41e949c8b76d9b14eeb13cbcfb584e7a0
parentd73717a4f6b243d40388bb1d3bb9db7421d7b9b0 (diff)
downloadDLT-daemon-be6f37ba05e19ae9dab4e3414c5e6d8ae502ccf5.tar.gz
Fix daemon shutdown
The shutdown of the daemon was not proper implemented. This commit fixes: - memory leaks - removal of created sockets Signed-off-by: Christoph Lipka <clipka@jp.adit-jv.com>
-rw-r--r--src/daemon/dlt-daemon.c37
-rw-r--r--src/daemon/dlt_daemon_unix_socket.h2
2 files changed, 31 insertions, 8 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index 02e42ec..79be6ba 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -659,13 +659,7 @@ int main(int argc, char* argv[])
dlt_daemon_log_internal(&daemon, &daemon_local, "Exiting Daemon...", daemon_local.flags.vflag);
- /* disconnect all logstorage devices */
- dlt_daemon_logstorage_cleanup(&daemon,
- &daemon_local,
- daemon_local.flags.vflag);
-
-
-// dlt_daemon_local_cleanup(&daemon, &daemon_local, daemon_local.flags.vflag);
+ dlt_daemon_local_cleanup(&daemon, &daemon_local, daemon_local.flags.vflag);
dlt_log(LOG_NOTICE, "Leaving DLT daemon\n");
@@ -1131,6 +1125,14 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
dlt_receiver_free(&(daemon_local->receiverSock));
/* Ignore result */
+ dlt_receiver_free(&(daemon_local->receiverCtrlSock));
+ /* Ignore result */
+ if (daemon_local->flags.yvalue[0])
+ {
+ /* Ignore result */
+ dlt_receiver_free(&(daemon_local->receiverSerial));
+ }
+ /* Ignore result */
dlt_message_free(&(daemon_local->msg),daemon_local->flags.vflag);
close(daemon_local->fp);
@@ -1144,6 +1146,9 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
} /* if */
#endif
+ /* free ringbuffer */
+ dlt_buffer_free_dynamic(&(daemon->client_ringbuffer));
+
/* Ignore result */
dlt_file_free(&(daemon_local->file),daemon_local->flags.vflag);
@@ -1158,6 +1163,24 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
/* Try to delete lock file, ignore result of unlink() */
unlink(DLT_DAEMON_LOCK_FILE);
+ if (daemon_local->flags.offlineLogstorageMaxDevices > 0)
+ {
+ /* disconnect all logstorage devices */
+ dlt_daemon_logstorage_cleanup(daemon,
+ daemon_local,
+ daemon_local->flags.vflag);
+
+ free(daemon->storage_handle);
+ }
+
+ if (daemon->ECUVersionString != NULL)
+ {
+ free(daemon->ECUVersionString);
+ }
+
+ dlt_daemon_unix_socket_close(daemon_local->ctrlsock);
+ unlink(daemon_local->flags.ctrlSockPath);
+
dlt_event_handler_cleanup_connections(&daemon_local->pEvent);
}
diff --git a/src/daemon/dlt_daemon_unix_socket.h b/src/daemon/dlt_daemon_unix_socket.h
index 5db4145..ec12eba 100644
--- a/src/daemon/dlt_daemon_unix_socket.h
+++ b/src/daemon/dlt_daemon_unix_socket.h
@@ -59,7 +59,7 @@
#define DLT_DAEMON_UNIX_SOCKET_H
int dlt_daemon_unix_socket_open(int *sock, char *socket_path);
-int dlt_daemon_socket_close(int sock);
+int dlt_daemon_unix_socket_close(int sock);
int dlt_daemon_unix_socket_send(int sock,void* data1,int size1,void* data2,
int size2,char serialheader);