Merge pull request #372 from heitbaum/5.0.0-fixes

fix multithreading mutex
master
Ronnie Sahlberg 2022-01-29 09:40:14 +10:00 committed by GitHub
commit 382905495f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View File

@ -4983,10 +4983,14 @@ nfs3_chdir_continue_internal(struct nfs_context *nfs,
struct nfs_cb_data *data)
{
/* steal saved_path */
#ifdef HAVE_MULTITHREADING
nfs_mt_mutex_lock(&nfs->rpc->rpc_mutex);
#endif
free(nfs->nfsi->cwd);
nfs->nfsi->cwd = data->saved_path;
#ifdef HAVE_MULTITHREADING
nfs_mt_mutex_unlock(&nfs->rpc->rpc_mutex);
#endif
data->saved_path = NULL;

View File

@ -643,6 +643,7 @@ nfs4_op_commit(struct nfs_context *nfs, nfs_argop4 *op)
return 1;
}
#ifdef HAVE_MULTITHREADING
static int
nfs4_op_release_lockowner(struct nfs_context *nfs, nfs_argop4 *op, struct nfsfh *fh)
{
@ -657,6 +658,7 @@ nfs4_op_release_lockowner(struct nfs_context *nfs, nfs_argop4 *op, struct nfsfh
return 1;
}
#endif
static int
nfs4_op_close(struct nfs_context *nfs, nfs_argop4 *op, struct nfsfh *fh)
@ -1687,10 +1689,14 @@ nfs4_chdir_1_cb(struct rpc_context *rpc, int status, void *command_data,
}
/* Ok, all good. Lets steal the path string. */
#ifdef HAVE_MULTITHREADING
nfs_mt_mutex_lock(&nfs->rpc->rpc_mutex);
#endif
free(nfs->nfsi->cwd);
nfs->nfsi->cwd = data->path;
#ifdef HAVE_MULTITHREADING
nfs_mt_mutex_unlock(&nfs->rpc->rpc_mutex);
#endif
data->path = NULL;
@ -2347,10 +2353,10 @@ nfs4_open_readlink_cb(struct rpc_context *rpc, int status, void *command_data,
#ifdef HAVE_MULTITHREADING
nfs_mt_mutex_lock(&data->nfs->nfsi->nfs4_open_mutex);
#endif
data->lock_owner = nfs->nfsi->open_counter++;
#ifdef HAVE_MULTITHREADING
nfs_mt_mutex_unlock(&data->nfs->nfsi->nfs4_open_mutex);
#else
data->lock_owner = nfs->nfsi->open_counter++;
#endif
data->filler.func = nfs4_populate_open;

View File

@ -165,7 +165,9 @@ int main(int argc, char *argv[])
struct client client;
struct statvfs stvfs;
struct nfs_url *url = NULL;
#ifdef HAVE_MULTITHREADING
int mt_started = 0;
#endif
#ifdef WIN32
if (WSAStartup(MAKEWORD(2,2), &wsaData) != 0) {
@ -247,6 +249,8 @@ int main(int argc, char *argv[])
fprintf(stderr, "Failed to mount nfs share : %s\n", nfs_get_error(nfs));
goto finished;
}
#ifdef HAVE_MULTITHREADING
/*
* Before we can use multithreading we must initialize and
* start the service thread.
@ -256,6 +260,7 @@ int main(int argc, char *argv[])
exit(10);
}
mt_started = 1;
#endif
process_dir(nfs, "", 16);
@ -270,10 +275,12 @@ int main(int argc, char *argv[])
ret = 0;
finished:
#ifdef HAVE_MULTITHREADING
if (mt_started) {
printf("closing service thread\n");
nfs_mt_service_thread_stop(nfs);
}
#endif
if (ret > 0) {
print_usage();