diff options
| author | Niels de Vos <ndevos@redhat.com> | 2016-08-06 16:04:48 +0200 |
|---|---|---|
| committer | Niels de Vos <ndevos@redhat.com> | 2016-09-28 11:00:38 -0700 |
| commit | 4721188a154acd9a0a4c096d8d73e97f3bf1b2a9 (patch) | |
| tree | 6f957b9cfd21c9fc9e72390d85520bc627e7fa9e /tests/basic/gfapi/bug1283983.c | |
| parent | 7407266684334203c21e260bb0b3527ca94bb507 (diff) | |
gfapi: redesign the public interface for upcall consumers
The glfs_callback_arg and glfs_callback_inode_arg were allocated by
gfapi, and expected to be free()'d by the application. However it is not
reasonable to expect that applications use the same memory allocator to
as the compiled libgfapi.so. For instance, it is possible that gfapi
uses glibc malloc/free, and an application like NFS-Ganesha the versions
from jemalloc. Mismatching of the malloc() and free() functions causes
segmentation faults at best.
In order to prevent problems like this in the future, the API for
applications that consume upcalls has been remodeled. Any of the
structures that gfapi allocates, should be free'd with glfs_free(). The
members of the structures can not be accessed directly anymore, each
has its own function to access now.
Correcting the naming of the functions, structures and constants is a
continuation of commit 2775dc64101ed37c8d9809bf9852dbf0746ee2b6. These
new improvements not only have correct prefixes for the functions and
structures, the naming also reflects more to the upcall framework and
does not use "callback" anymore.
Change-Id: I2b8bd5a0a82036d2abea1a217f5e5975a1d4fe93
BUG: 1344714
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/14701
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: soumya k <skoduri@redhat.com>
Reviewed-by: jiffin tony Thottan <jthottan@redhat.com>
Diffstat (limited to 'tests/basic/gfapi/bug1283983.c')
| -rw-r--r-- | tests/basic/gfapi/bug1283983.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/tests/basic/gfapi/bug1283983.c b/tests/basic/gfapi/bug1283983.c index 6583097697b..3334b290d9e 100644 --- a/tests/basic/gfapi/bug1283983.c +++ b/tests/basic/gfapi/bug1283983.c @@ -31,20 +31,18 @@ int gfapi = 1; int main (int argc, char *argv[]) { - glfs_t *fs = NULL; - int ret = 0, i; - glfs_fd_t *fd = NULL; - char *filename = "/a1"; - char *filename2 = "/a2"; - struct stat sb = {0, }; - struct glfs_callback_arg cbk; - char *logfile = NULL; - char *volname = NULL; - int cnt = 1; - struct glfs_callback_inode_arg *in_arg = NULL; - struct glfs_object *root = NULL, *leaf = NULL; - - cbk.reason = 0; + glfs_t *fs = NULL; + int ret = 0, i; + glfs_fd_t *fd = NULL; + char *filename = "/a1"; + char *filename2 = "/a2"; + struct stat sb = {0, }; + struct glfs_upcall *cbk = NULL; + char *logfile = NULL; + char *volname = NULL; + int cnt = 1; + struct glfs_upcall_inode *in_arg = NULL; + struct glfs_object *root = NULL, *leaf = NULL; fprintf (stderr, "Starting libgfapi_fini\n"); if (argc != 4) { @@ -105,11 +103,13 @@ main (int argc, char *argv[]) LOG_ERR ("glfs_h_poll_upcall", ret); /* There should not be any upcalls sent */ - if (cbk.reason != GFAPI_CBK_EVENT_NULL) { + if (glfs_upcall_get_reason(cbk) != GLFS_UPCALL_EVENT_NULL) { fprintf (stderr, "Error: Upcall received(%d)\n", - cbk.reason); + glfs_upcall_get_reason(cbk)); exit (1); } + + glfs_free (cbk); } ret = glfs_fini(fs); |
