diff options
author | Saravanakumar Arumugam <sarumuga@redhat.com> | 2015-04-29 17:33:43 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-05-08 06:14:12 -0700 |
commit | 1b42cb507c3f72225f03a4715e051d9eb8c08e43 (patch) | |
tree | 1d4011ec1e728e0f2a0b22d7b9927e1702f266fe /xlators/features/changelog/lib | |
parent | e1ad65b6eadc8c607c46c1b8528df25de5726ecc (diff) |
features/changelog: Avoid creation of empty changelogs
An empty changelog when rolled over gets unlinked and indexed with
a modified path-name in htime file. The modification is "changelog"
not "CHANGELOG" in basename of the empty changelog file.
BUG: 1219479
Change-Id: Ib5b825ab563fa34d8dcf4368cf6cbf4b25d78a6d
Original-Author: Ajeet Jha <ajha@redhat.com>
Original-Author: Saravanakumar Arumugam <sarumuga@redhat.com>
Reviewed-On: http://review.gluster.org/#/c/9572/
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Reviewed-on: http://review.gluster.org/10642
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Aravinda VK <avishwan@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/features/changelog/lib')
-rw-r--r-- | xlators/features/changelog/lib/src/gf-history-changelog.c | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/xlators/features/changelog/lib/src/gf-history-changelog.c b/xlators/features/changelog/lib/src/gf-history-changelog.c index 50afb3fe0c7..ba312e3b10f 100644 --- a/xlators/features/changelog/lib/src/gf-history-changelog.c +++ b/xlators/features/changelog/lib/src/gf-history-changelog.c @@ -477,6 +477,36 @@ out: return -1; } +/* + * Description: Checks if the changelog path is usable or not, + * which is differenciated by checking for "changelog" + * in the path and not "CHANGELOG". + * + * Returns: + * 1 : Yes, usable ( contains "CHANGELOG" ) + * 0 : No, Not usable ( contains, "changelog") + */ +int +gf_is_changelog_usable (char *cl_path) +{ + int ret = -1; + const char low_c[] = "changelog"; + char *str_ret = NULL; + char *bname = NULL; + + bname = basename (cl_path); + + str_ret = strstr (bname, low_c); + + if (str_ret != NULL) + ret = 0; + else + ret = 1; + + return ret; + +} + void * gf_changelog_consume_wrap (void* data) { @@ -499,15 +529,16 @@ gf_changelog_consume_wrap (void* data) } /* TODO: handle short reads and EOF. */ + if (gf_is_changelog_usable (ccd->changelog) == 1) { - ret = gf_changelog_consume (ccd->this, - ccd->jnl, ccd->changelog, _gf_true); - if (ret) { - gf_log (this->name, GF_LOG_ERROR, - "could not parse changelog: %s", ccd->changelog); - goto out; + ret = gf_changelog_consume (ccd->this, + ccd->jnl, ccd->changelog, _gf_true); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, + "could not parse changelog: %s", ccd->changelog); + goto out; + } } - ccd->retval = 0; out: |