summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-scrub-svc.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-scrub-svc.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c b/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c
index 36863e2a248..b5c97850a75 100644
--- a/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c
+++ b/xlators/mgmt/glusterd/src/glusterd-scrub-svc.c
@@ -17,13 +17,18 @@
char *scrub_svc_name = "scrub";
+void
+glusterd_scrubsvc_build (glusterd_svc_t *svc)
+{
+ svc->manager = glusterd_scrubsvc_manager;
+ svc->start = glusterd_scrubsvc_start;
+ svc->stop = glusterd_scrubsvc_stop;
+}
+
int
glusterd_scrubsvc_init (glusterd_svc_t *svc)
{
- return glusterd_svc_init (svc, scrub_svc_name,
- glusterd_scrubsvc_manager,
- glusterd_scrubsvc_start,
- glusterd_scrubsvc_stop);
+ return glusterd_svc_init (svc, scrub_svc_name);
}
static int
@@ -60,6 +65,20 @@ glusterd_scrubsvc_manager (glusterd_svc_t *svc, void *data, int flags)
{
int ret = -EINVAL;
+ if (!svc->inited) {
+ ret = glusterd_scrubsvc_init (svc);
+ if (ret) {
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_SCRUB_INIT_FAIL, "Failed to init "
+ "scrub service");
+ goto out;
+ } else {
+ svc->inited = _gf_true;
+ gf_msg_debug (THIS->name, 0, "scrub service "
+ "initialized");
+ }
+ }
+
if (glusterd_should_i_stop_bitd ()) {
ret = svc->stop (svc, SIGTERM);
} else {