summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2011-04-18 17:25:31 +0000
committerAnand Avati <avati@gluster.com>2011-04-19 02:30:47 -0700
commit3776483431bfcd867a07b83ebd7d303a5d3538b6 (patch)
tree99b1149bee65a36347db0dcb429d870ee10ea356 /xlators/mgmt/glusterd/src
parentced2d41bfdf6ee3ee820fa6090e4bf3147ab0d84 (diff)
glusterd / geo-rep: harvesting further benefits of static gsyncd pre-config
- log-file does not need to be a reserved option anymore as we wouldn't overwrite the user setting - reimplement glusterd_gsync_get_param_file(): all use cases have now pre-configured values, so instead of putting together the needed pathname by ourselves, we can just get it from gsyncd config - refactor it to a common backend with glusterd_get_canon_url() Signed-off-by: Csaba Henk <csaba@lowlife.hu> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2785 (gsyncd logs on slave side go to /dev/null) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2785
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c82
1 files changed, 34 insertions, 48 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 0bae57847b9..7003c579362 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -98,7 +98,6 @@ static char *glusterd_op_sm_event_names[] = {
static char *gsync_reserved_opts[] = {
"gluster-command",
"pid-file",
- "log-file",
"state-file",
"session-owner",
NULL
@@ -1724,33 +1723,21 @@ out:
}
-static int
-glusterd_get_canon_url (char *cann, char *name, gf_boolean_t cann_esc)
+int
+glusterd_query_extutil (char *resbuf, char *cmd)
{
- FILE *in = NULL;
- char buff[PATH_MAX] = {0, };
- char cmd[PATH_MAX] = {0, };
+ FILE *in = NULL;
char *ptr = NULL;
- glusterd_conf_t *priv = NULL;
int ret = 0;
- GF_ASSERT (THIS);
- GF_ASSERT (THIS->private);
-
- priv = THIS->private;
-
- snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd --canonicalize-%surl %s",
- cann_esc? "escape-": "",name);
if (!(in = popen(cmd, "r"))) {
gf_log ("", GF_LOG_ERROR, "popen failed");
return -1;
}
- ptr = fgets(buff, sizeof(buff), in);
- if (ptr) {
- buff[strlen(buff)-1]='\0'; //strip off \n
- strncpy (cann, buff, PATH_MAX);
- }
+ ptr = fgets(resbuf, PATH_MAX, in);
+ if (ptr)
+ resbuf[strlen(resbuf)-1] = '\0'; //strip off \n
ret |= pclose (in);
@@ -1758,43 +1745,42 @@ glusterd_get_canon_url (char *cann, char *name, gf_boolean_t cann_esc)
gf_log ("", GF_LOG_ERROR, "popen failed");
return ret ? -1 : 0;
-
}
-int
-glusterd_gsync_get_param_file (char *prmfile, const char *ext, char *master,
- char *slave, char *gl_workdir)
+static int
+glusterd_get_canon_url (char *cann, char *name, gf_boolean_t cann_esc)
{
- char buff[PATH_MAX] = {0, };
- char *dotp = NULL;
- int ret = 0;
+ char cmd[PATH_MAX] = {0, };
+ glusterd_conf_t *priv = NULL;
+
+ GF_ASSERT (THIS);
+ GF_ASSERT (THIS->private);
- if (!(master && slave && gl_workdir)) {
- GF_ASSERT (!master && !slave && !gl_workdir);
- /* extension adjustment mode */
+ priv = THIS->private;
- dotp = strrchr (prmfile, '.');
- if (!dotp++ ||
- /* overflow */
- dotp - prmfile + strlen (ext) + 1 > PATH_MAX)
- return -1;
+ snprintf (cmd, PATH_MAX, GSYNCD_PREFIX"/gsyncd --canonicalize-%surl %s",
+ cann_esc? "escape-": "",name);
- strcpy (dotp, ext);
- return 0;
- }
+ return glusterd_query_extutil (cann, cmd);
+}
- ret = glusterd_get_canon_url (buff, slave, _gf_true);
+int
+glusterd_gsync_get_param_file (char *prmfile, const char *param, char *master,
+ char *slave, char *gl_workdir)
+{
+ char cmd[PATH_MAX] = {0, };
+ glusterd_conf_t *priv = NULL;
- if (ret) {
- gf_log ("", GF_LOG_WARNING, "Unable to cannonicalize slave URL"
- "of %s", slave);
- return -1;
- }
+ GF_ASSERT (THIS);
+ GF_ASSERT (THIS->private);
- snprintf (prmfile, PATH_MAX, "%s/"GEOREP"/%s/%s.%s", gl_workdir, master,
- buff, ext);
+ priv = THIS->private;
- return 0;
+ snprintf (cmd, PATH_MAX,
+ GSYNCD_PREFIX"/gsyncd -c %s/"GSYNC_CONF" :%s %s --config-get %s-file",
+ gl_workdir, master, slave, param);
+
+ return glusterd_query_extutil (prmfile, cmd);
}
static int
@@ -4303,8 +4289,8 @@ glusterd_read_status_file (char *master, char *slave,
GF_ASSERT (THIS->private);
priv = THIS->private;
- ret = glusterd_gsync_get_param_file (statusfile, "status", master,
- slave, priv->workdir);
+ ret = glusterd_gsync_get_param_file (statusfile, "state", master,
+ slave, priv->workdir);
if (ret) {
gf_log ("", GF_LOG_WARNING, "Unable to get the name of status"
"file for %s(master), %s(slave)", master, slave);