From 2f5355f76a8168bc504cba8237f0825fc181fce8 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Wed, 1 Jul 2015 12:06:42 +0530 Subject: libgfchangelog: Fix example programs Incorporate the new API 'gf_changelog_init' introduced in libgfchangelog which should be called before 'gf_changelog_register'. Change-Id: I10a9dd5ff3ecc64fd61dcb6b1aa53739e0bdeedd BUG: 1238063 Signed-off-by: Kotresh HR Reviewed-on: http://review.gluster.org/11479 Tested-by: NetBSD Build System Reviewed-by: Venky Shankar Tested-by: Gluster Build System --- xlators/features/changelog/lib/examples/python/changes.py | 3 ++- xlators/features/changelog/lib/examples/python/libgfchangelog.py | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'xlators/features/changelog/lib/examples/python') diff --git a/xlators/features/changelog/lib/examples/python/changes.py b/xlators/features/changelog/lib/examples/python/changes.py index d21db8eab2e..221df642a36 100644 --- a/xlators/features/changelog/lib/examples/python/changes.py +++ b/xlators/features/changelog/lib/examples/python/changes.py @@ -10,6 +10,7 @@ cl = libgfchangelog.Changes() def get_changes(brick, scratch_dir, log_file, log_level, interval): change_list = [] try: + cl.cl_init() cl.cl_register(brick, scratch_dir, log_file, log_level) while True: cl.cl_scan() @@ -25,7 +26,7 @@ def get_changes(brick, scratch_dir, log_file, log_level, interval): print ex if __name__ == '__main__': - if len(sys.argv) != 5: + if len(sys.argv) != 6: print("usage: %s " % (sys.argv[0])) sys.exit(1) diff --git a/xlators/features/changelog/lib/examples/python/libgfchangelog.py b/xlators/features/changelog/lib/examples/python/libgfchangelog.py index 68ec3baf144..10e73c02b34 100644 --- a/xlators/features/changelog/lib/examples/python/libgfchangelog.py +++ b/xlators/features/changelog/lib/examples/python/libgfchangelog.py @@ -3,7 +3,7 @@ from ctypes import * from ctypes.util import find_library class Changes(object): - libgfc = CDLL(find_library("gfchangelog"), use_errno=True) + libgfc = CDLL(find_library("gfchangelog"), mode=RTLD_GLOBAL, use_errno=True) @classmethod def geterrno(cls): @@ -18,6 +18,12 @@ class Changes(object): def _get_api(cls, call): return getattr(cls.libgfc, call) + @classmethod + def cl_init(cls): + ret = cls._get_api('gf_changelog_init')(None) + if ret == -1: + cls.raise_changelog_err() + @classmethod def cl_register(cls, brick, path, log_file, log_level, retries = 0): ret = cls._get_api('gf_changelog_register')(brick, path, -- cgit