summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeevan Ramakant Nagvekar <jeevan.nagvekar1@wipro.com>2018-07-27 16:00:44 +0530
committerManikandan C <mchockalingam@de.adit-jv.com>2018-12-17 18:22:51 +0100
commit27a1cba2fac7c687599cf105e5c9133bb4eca443 (patch)
tree6f733e5de57ff3f0f1235da13ddbdfaa1793813f
parent1d38259d4067fd34d74a416d877ae1c42913b5aa (diff)
downloadDLT-daemon-27a1cba2fac7c687599cf105e5c9133bb4eca443.tar.gz
Remove one-instance-lock mechanism
This commit removes DLT's "one-instance-lock" mechanism. In daemonized mode, on first instance, a file is created (if not already created) and locked. If second instance is attempted file locking fails since the file is already locked by first instance. This prevents new instance of the DLT daemon. After analysis its found that there is no need of any mechanism for prevention of another instance. The same is already taken care by socket mechanism. Since main socket is created by first instance, attempt to create it again with same port number fails. Signed-off-by: Jeevan Ramakant Nagvekar <jeevan.nagvekar1@wipro.com>
-rw-r--r--src/daemon/dlt-daemon.c32
-rw-r--r--src/daemon/dlt-daemon_cfg.h5
2 files changed, 1 insertions, 36 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index 5c65613..660932c 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -1338,9 +1338,6 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
dlt_shm_free_server(&(daemon_local->dlt_shm));
#endif
- /* Try to delete lock file, ignore result of unlink() */
- unlink(DLT_DAEMON_LOCK_FILE);
-
if (daemon_local->flags.offlineLogstorageMaxDevices > 0)
{
/* disconnect all logstorage devices */
@@ -1367,9 +1364,6 @@ void dlt_daemon_exit_trigger()
snprintf(tmp, PATH_MAX, "%s/dlt", dltFifoBaseDir);
(void)unlink(tmp);
- snprintf(tmp, PATH_MAX, "%s/%s", dltFifoBaseDir, DLT_DAEMON_LOCK_FILE);
- (void)unlink(tmp);
-
/* stop event loop */
g_exit = -1;
}
@@ -1400,8 +1394,7 @@ void dlt_daemon_signal_handler(int sig)
void dlt_daemon_daemonize(int verbose)
{
- int i,lfp;
- ssize_t pid_len;
+ int i;
PRINT_FUNCTION_VERBOSE(verbose);
@@ -1456,29 +1449,6 @@ void dlt_daemon_daemonize(int verbose)
dlt_log(LOG_WARNING, str);
}
- /* Ensure single copy of daemon; if started with same directory
- run only one instance at a time */
- char dlt_daemon_lock_file[PATH_MAX + 1];
- snprintf(dlt_daemon_lock_file, PATH_MAX, "%s/%s", dltFifoBaseDir, DLT_DAEMON_LOCK_FILE);
- dlt_daemon_lock_file[PATH_MAX] = 0;
- lfp=open(dlt_daemon_lock_file,O_RDWR|O_CREAT,DLT_DAEMON_LOCK_FILE_PERM);
- if (lfp<0)
- {
- dlt_log(LOG_CRIT, "Can't open lock file, exiting DLT daemon\n");
- exit(-1); /* can not open */
- }
- if (lockf(lfp,F_TLOCK,0)<0)
- {
- dlt_log(LOG_CRIT, "Can't lock lock file, exiting DLT daemon\n");
- exit(-1); /* can not lock */
- }
- /* only first instance continues */
-
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"%d\n",getpid());
- pid_len = strlen(str);
- if(write(lfp,str,pid_len) != pid_len) /* record pid to lockfile */
- dlt_log(LOG_WARNING, "Could not write pid to file in dlt_daemon_daemonize.\n");
-
/* Catch signals */
signal(SIGCHLD,SIG_IGN); /* ignore child */
signal(SIGTSTP,SIG_IGN); /* ignore tty signals */
diff --git a/src/daemon/dlt-daemon_cfg.h b/src/daemon/dlt-daemon_cfg.h
index 8870217..ff3a042 100644
--- a/src/daemon/dlt-daemon_cfg.h
+++ b/src/daemon/dlt-daemon_cfg.h
@@ -94,13 +94,8 @@
/* Maximum length of a description */
#define DLT_DAEMON_DESCSIZE 256
-/* Name of daemon lock file, contain process id of dlt daemon instance */
-#define DLT_DAEMON_LOCK_FILE "dltd.lock"
-
/* Umask of daemon, creates files with permission 750 */
#define DLT_DAEMON_UMASK 027
-/* Permissions of daemon lock file */
-#define DLT_DAEMON_LOCK_FILE_PERM 0640
/* Default ECU ID, used in storage header and transmitted to client*/
#define DLT_DAEMON_ECU_ID "ECU1"