s3: VFS: vfs_glusterfs. Pass in struct vfs_gluster_pread_state as the callback data...
authorJeremy Allison <jra@samba.org>
Fri, 28 Feb 2020 23:35:46 +0000 (15:35 -0800)
committerJeremy Allison <jra@samba.org>
Sun, 8 Mar 2020 18:07:43 +0000 (18:07 +0000)
Find the req we're finishing off by looking inside vfs_gluster_pread_state.
In a shutdown close the caller calls talloc_free(req), so we can't
access it directly as callback data.

The next commit will NULL out the vfs_gluster_pread_state->req pointer
when a caller calls talloc_free(req), and the request is still in
flight.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14301

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/modules/vfs_glusterfs.c

index 6598aadad17413a88f32f520ae5f343d04d9285c..84b284152c675dc43bd1e66f6d402c6c47dca9ec 100644 (file)
@@ -766,7 +766,7 @@ static struct tevent_req *vfs_gluster_pread_send(struct vfs_handle_struct
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
-       tevent_req_set_callback(subreq, vfs_gluster_pread_done, req);
+       tevent_req_set_callback(subreq, vfs_gluster_pread_done, state);
 
        talloc_set_destructor(state, vfs_gluster_pread_state_destructor);
 
@@ -812,10 +812,9 @@ static int vfs_gluster_pread_state_destructor(struct vfs_gluster_pread_state *st
 
 static void vfs_gluster_pread_done(struct tevent_req *subreq)
 {
-       struct tevent_req *req = tevent_req_callback_data(
-               subreq, struct tevent_req);
-       struct vfs_gluster_pread_state *state = tevent_req_data(
-               req, struct vfs_gluster_pread_state);
+       struct vfs_gluster_pread_state *state = tevent_req_callback_data(
+               subreq, struct vfs_gluster_pread_state);
+       struct tevent_req *req = state->req;
        int ret;
 
        ret = pthreadpool_tevent_job_recv(subreq);