diff options
Diffstat (limited to 'source/lib')
-rw-r--r-- | source/lib/gencache.c | 11 | ||||
-rw-r--r-- | source/lib/pidfile.c | 13 |
2 files changed, 15 insertions, 9 deletions
diff --git a/source/lib/gencache.c b/source/lib/gencache.c index 75a8f2f1e16..013eed8a00d 100644 --- a/source/lib/gencache.c +++ b/source/lib/gencache.c @@ -56,13 +56,9 @@ BOOL gencache_init(void) /* skip file open if it's already opened */ if (cache) return True; - asprintf(&cache_fname, "%s/%s", lp_lockdir(), "gencache.tdb"); - if (cache_fname) - DEBUG(5, ("Opening cache file at %s\n", cache_fname)); - else { - DEBUG(0, ("Filename allocation failed.\n")); - return False; - } + cache_fname = lock_path("gencache.tdb"); + + DEBUG(5, ("Opening cache file at %s\n", cache_fname)); cache = tdb_open_log(cache_fname, 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0644); @@ -75,7 +71,6 @@ BOOL gencache_init(void) } } - SAFE_FREE(cache_fname); if (!cache) { DEBUG(5, ("Attempt to open gencache.tdb has failed.\n")); return False; diff --git a/source/lib/pidfile.c b/source/lib/pidfile.c index 08e41083b59..49626acade5 100644 --- a/source/lib/pidfile.c +++ b/source/lib/pidfile.c @@ -78,13 +78,24 @@ pid_t pidfile_pid(const char *name) } /* create a pid file in the pid directory. open it and leave it locked */ -void pidfile_create(const char *name) +void pidfile_create(const char *program_name) { int fd; char buf[20]; + char *short_configfile; + pstring name; pstring pidFile; pid_t pid; + /* Add a suffix to the program name if this is a process with a + * none default configuration file name. */ + if (strcmp( CONFIGFILE, dyn_CONFIGFILE) == 0) { + strncpy( name, program_name, sizeof( name)-1); + } else { + short_configfile = strrchr( dyn_CONFIGFILE, '/'); + slprintf( name, sizeof( name)-1, "%s-%s", program_name, short_configfile+1); + } + slprintf(pidFile, sizeof(pidFile)-1, "%s/%s.pid", lp_piddir(), name); pid = pidfile_pid(name); |