From 5f5ef3c7123057a5d4a3b0eae86e1e388558009b Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Mon, 16 Jun 2014 23:33:33 +1000 Subject: [PATCH] Parse and store the socket directory and name for ckdb --- src/ckpool.c | 17 ++++++++++++++++- src/ckpool.h | 5 +++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/ckpool.c b/src/ckpool.c index 3d01ca32..afc8d4cc 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -750,11 +750,14 @@ int main(int argc, char **argv) memset(&ckp, 0, sizeof(ckp)); ckp.loglevel = LOG_NOTICE; - while ((c = getopt(argc, argv, "c:g:kl:n:ps:")) != -1) { + while ((c = getopt(argc, argv, "c:d:g:kl:n:pS:s:")) != -1) { switch (c) { case 'c': ckp.config = optarg; break; + case 'd': + ckp.ckdb_name = optarg; + break; case 'g': ckp.grpnam = optarg; break; @@ -774,6 +777,8 @@ int main(int argc, char **argv) case 'p': ckp.proxy = true; break; + case 'S': + ckp.ckdb_sockdir = strdup(optarg); case 's': ckp.socket_dir = strdup(optarg); break; @@ -809,6 +814,16 @@ int main(int argc, char **argv) } trail_slash(&ckp.socket_dir); + if (!ckp.ckdb_name) + ckp.ckdb_name = "ckdb"; + if (!ckp.ckdb_sockdir) { + ckp.ckdb_sockdir = strdup("/opt/"); + realloc_strcat(&ckp.ckdb_sockdir, ckp.ckdb_name); + } + trail_slash(&ckp.ckdb_sockdir); + ckp.ckdb_sockname = ckp.ckdb_sockdir; + realloc_strcat(&ckp.ckdb_sockdir, "listener"); + /* Ignore sigpipe */ signal(SIGPIPE, SIG_IGN); diff --git a/src/ckpool.h b/src/ckpool.h index 2d7e361f..d6266979 100644 --- a/src/ckpool.h +++ b/src/ckpool.h @@ -67,6 +67,11 @@ struct ckpool_instance { char *name; /* Directory where sockets are created */ char *socket_dir; + /* Directory where ckdb sockets are */ + char *ckdb_sockdir; + /* Name of the ckdb process */ + char *ckdb_name; + char *ckdb_sockname; /* Group ID for unix sockets */ char *grpnam; gid_t gr_gid;