diff options
Diffstat (limited to 'tests/basic/gfapi/bug1291259.c')
-rw-r--r-- | tests/basic/gfapi/bug1291259.c | 70 |
1 files changed, 46 insertions, 24 deletions
diff --git a/tests/basic/gfapi/bug1291259.c b/tests/basic/gfapi/bug1291259.c index 35f39938cb3..2169ba8c240 100644 --- a/tests/basic/gfapi/bug1291259.c +++ b/tests/basic/gfapi/bug1291259.c @@ -34,24 +34,22 @@ int gfapi = 1; int main (int argc, char *argv[]) { - glfs_t *fs = NULL; - glfs_t *fs2 = NULL; - int ret = 0, i; - glfs_fd_t *fd = NULL; - char *filename = "/a1"; - char *filename2 = "/a2"; - struct stat sb = {0, }; - struct callback_arg cbk; - char *logfile = NULL; - char *volname = NULL; - int cnt = 1; - int upcall_received = 0; - struct callback_inode_arg *in_arg = NULL; - struct glfs_object *root = NULL, *leaf = NULL; - unsigned char globjhdl[GFAPI_HANDLE_LENGTH]; - unsigned char globjhdl2[GFAPI_HANDLE_LENGTH]; - - cbk.reason = 0; + glfs_t *fs = NULL; + glfs_t *fs2 = NULL; + int ret = 0, i; + glfs_fd_t *fd = NULL; + char *filename = "/a1"; + char *filename2 = "/a2"; + struct stat sb = {0, }; + char *logfile = NULL; + char *volname = NULL; + char *hostname = NULL; + int cnt = 1; + int upcall_received = 0; + struct glfs_upcall *cbk = NULL; + struct glfs_object *root = NULL, *leaf = NULL; + unsigned char globjhdl[GFAPI_HANDLE_LENGTH]; + unsigned char globjhdl2[GFAPI_HANDLE_LENGTH]; fprintf (stderr, "Starting libgfapi_fini\n"); if (argc != 3) { @@ -78,6 +76,12 @@ main (int argc, char *argv[]) ret = glfs_init (fs); LOG_ERR("glfs_init", ret); + /* This does not block, but enables caching of events. Real + * applications like NFS-Ganesha run this in a thread before activity + * on the fs (through this instance) happens. */ + ret = glfs_h_poll_upcall(fs, &cbk); + LOG_ERR ("glfs_h_poll_upcall", ret); + fs2 = glfs_new (volname); if (!fs) { fprintf (stderr, "glfs_new: returned NULL\n"); @@ -117,21 +121,30 @@ main (int argc, char *argv[]) } fprintf (stderr, "glfs_h_create leaf - %p\n", leaf); - while (cnt++ < 5) { + while (cnt++ < 5 && !upcall_received) { + enum glfs_upcall_reason reason = 0; + struct glfs_upcall_inode *in_arg = NULL; + ret = glfs_h_poll_upcall(fs, &cbk); LOG_ERR ("glfs_h_poll_upcall", ret); + if (ret) + goto retry; + + reason = glfs_upcall_get_reason (cbk); + fprintf (stderr, "Upcall received(%d)\n", reason); + + if (reason == GLFS_UPCALL_INODE_INVALIDATE) { + struct glfs_object *object = NULL; - if (cbk.reason == GFAPI_INODE_INVALIDATE) { - fprintf (stderr, "Upcall received(%d)\n", - cbk.reason); - in_arg = (struct callback_inode_arg *)(cbk.event_arg); + in_arg = glfs_upcall_get_event (cbk); + object = glfs_upcall_inode_get_object (in_arg); ret = glfs_h_extract_handle (root, globjhdl+GLAPI_UUID_LENGTH, GFAPI_HANDLE_LENGTH); LOG_ERR("glfs_h_extract_handle", (ret != 16)); - ret = glfs_h_extract_handle (in_arg->object, + ret = glfs_h_extract_handle (object, globjhdl2+GLAPI_UUID_LENGTH, GFAPI_HANDLE_LENGTH); LOG_ERR("glfs_h_extract_handle", (ret != 16)); @@ -143,6 +156,15 @@ main (int argc, char *argv[]) } upcall_received = 1; } + +retry: + if (!upcall_received) + sleep (1); /* glfs_h_poll_upcall() does not block */ + + if (!ret) { + glfs_free (cbk); + cbk = NULL; + } } if (!upcall_received) { |