static int vfs_gluster_pread_state_destructor(struct vfs_gluster_pread_state *state)
{
+ /*
+ * This destructor only gets called if the request is still
+ * in flight, which is why we deny it by returning -1. We
+ * also set the req pointer to NULL so the _done function
+ * can detect the caller doesn't want the result anymore.
+ *
+ * Forcing the fsp closed by a SHUTDOWN_CLOSE can cause this.
+ */
+ state->req = NULL;
return -1;
}
TALLOC_FREE(subreq);
SMBPROFILE_BYTES_ASYNC_END(state->profile_bytes);
talloc_set_destructor(state, NULL);
+ if (req == NULL) {
+ /*
+ * We were shutdown closed in flight. No one
+ * wants the result, and state has been reparented
+ * to the NULL context, so just free it so we
+ * don't leak memory.
+ */
+ DBG_NOTICE("gluster pread request abandoned in flight\n");
+ TALLOC_FREE(state);
+ return;
+ }
if (ret != 0) {
if (ret != EAGAIN) {
tevent_req_error(req, ret);