diff options
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/features/changelog/src/changelog-encoders.c | 20 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-encoders.h | 2 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog-helpers.c | 4 | ||||
-rw-r--r-- | xlators/features/changelog/src/changelog.c | 17 |
4 files changed, 26 insertions, 17 deletions
diff --git a/xlators/features/changelog/src/changelog-encoders.c b/xlators/features/changelog/src/changelog-encoders.c index c71ea9270b0..553eec85c30 100644 --- a/xlators/features/changelog/src/changelog-encoders.c +++ b/xlators/features/changelog/src/changelog-encoders.c @@ -154,3 +154,23 @@ changelog_encode_binary (xlator_t *this, changelog_log_data_t *cld) return changelog_write_change (priv, buffer, off); } + +static struct changelog_encoder +cb_encoder[] = { + [CHANGELOG_ENCODE_BINARY] = + { + .encoder = CHANGELOG_ENCODE_BINARY, + .encode = changelog_encode_binary, + }, + [CHANGELOG_ENCODE_ASCII] = + { + .encoder = CHANGELOG_ENCODE_ASCII, + .encode = changelog_encode_ascii, + }, +}; + +void +changelog_encode_change( changelog_priv_t * priv) +{ + priv->ce = &cb_encoder[priv->encode_mode]; +} diff --git a/xlators/features/changelog/src/changelog-encoders.h b/xlators/features/changelog/src/changelog-encoders.h index 43deb1307d7..a3efbee05ee 100644 --- a/xlators/features/changelog/src/changelog-encoders.h +++ b/xlators/features/changelog/src/changelog-encoders.h @@ -40,5 +40,7 @@ int changelog_encode_binary (xlator_t *, changelog_log_data_t *); int changelog_encode_ascii (xlator_t *, changelog_log_data_t *); +void +changelog_encode_change(changelog_priv_t *); #endif /* _CHANGELOG_ENCODERS_H */ diff --git a/xlators/features/changelog/src/changelog-helpers.c b/xlators/features/changelog/src/changelog-helpers.c index c1bb6e5fef9..7ab0091b592 100644 --- a/xlators/features/changelog/src/changelog-helpers.c +++ b/xlators/features/changelog/src/changelog-helpers.c @@ -21,6 +21,7 @@ #include "changelog-helpers.h" #include "changelog-mem-types.h" +#include "changelog-encoders.h" #include <pthread.h> void @@ -201,7 +202,7 @@ changelog_open (xlator_t *this, (void) snprintf (buffer, 1024, CHANGELOG_HEADER, CHANGELOG_VERSION_MAJOR, CHANGELOG_VERSION_MINOR, - priv->encode_mode); + priv->ce->encoder); ret = changelog_write_change (priv, buffer, strlen (buffer)); if (ret) { close (priv->changelog_fd); @@ -267,6 +268,7 @@ changelog_handle_change (xlator_t *this, int ret = 0; if (CHANGELOG_TYPE_IS_ROLLOVER (cld->cld_type)) { + changelog_encode_change(priv); ret = changelog_start_next_change (this, priv, cld->cld_roll_time, cld->cld_finale); diff --git a/xlators/features/changelog/src/changelog.c b/xlators/features/changelog/src/changelog.c index 0a70fa0c760..cea0e8c70b5 100644 --- a/xlators/features/changelog/src/changelog.c +++ b/xlators/features/changelog/src/changelog.c @@ -36,20 +36,6 @@ cb_bootstrap[] = { }, }; -static struct changelog_encoder -cb_encoder[] = { - [CHANGELOG_ENCODE_BINARY] = - { - .encoder = CHANGELOG_ENCODE_BINARY, - .encode = changelog_encode_binary, - }, - [CHANGELOG_ENCODE_ASCII] = - { - .encoder = CHANGELOG_ENCODE_ASCII, - .encode = changelog_encode_ascii, - }, -}; - /* Entry operations - TYPE III */ /** @@ -1363,8 +1349,7 @@ init (xlator_t *this) GF_OPTION_INIT ("fsync-interval", priv->fsync_interval, int32, out); - GF_ASSERT (cb_encoder[priv->encode_mode].encoder == priv->encode_mode); - priv->ce = &cb_encoder[priv->encode_mode]; + changelog_encode_change(priv); GF_ASSERT (cb_bootstrap[priv->op_mode].mode == priv->op_mode); priv->cb = &cb_bootstrap[priv->op_mode]; |