summaryrefslogtreecommitdiff
path: root/src/daemon/dlt-daemon.c
diff options
context:
space:
mode:
authorJeevan Ramakant Nagvekar <jeevan.nagvekar1@wipro.com>2018-07-27 16:00:44 +0530
committerChristoph Lipka <clipka@users.noreply.github.com>2018-12-21 10:16:46 +0100
commit744b0d0c6b9231250dff00ed873e9cd5966da3ff (patch)
treef0589f531d32f1d512d45b51a406917489a5838b /src/daemon/dlt-daemon.c
parentc42a2bd8030113be0275ed07e1bc48779f607eec (diff)
downloadDLT-daemon-744b0d0c6b9231250dff00ed873e9cd5966da3ff.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>
Diffstat (limited to 'src/daemon/dlt-daemon.c')
-rw-r--r--src/daemon/dlt-daemon.c32
1 files changed, 1 insertions, 31 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 */