diff options
author | Bernd Schubert <bschubert@ddn.com> | 2022-04-11 12:02:54 +0200 |
---|---|---|
committer | Nikolaus Rath <Nikolaus@rath.org> | 2022-09-04 13:07:15 +0100 |
commit | d823cab63ad61a5b9ba09e6f4ccfd246572cd5e3 (patch) | |
tree | 18a3b2e6c570fb4312ad7f3488d90f7305de48e1 /lib | |
parent | af5710e7a3ad42e1b64ee8882fd72b22ffe271ac (diff) | |
download | fuse-d823cab63ad61a5b9ba09e6f4ccfd246572cd5e3.tar.gz |
fuse_session_loop_mt: Accept a NULL config - use defaults
If an application does not want to bother with the session
and wants to keep defaults, it can now just pass a NULL
as config parameter.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fuse_loop_mt.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/lib/fuse_loop_mt.c b/lib/fuse_loop_mt.c index 9ec1fb2..6002e19 100644 --- a/lib/fuse_loop_mt.c +++ b/lib/fuse_loop_mt.c @@ -328,10 +328,18 @@ int fuse_session_loop_mt_312(struct fuse_session *se, struct fuse_loop_config *c int err; struct fuse_mt mt; struct fuse_worker *w; + int created_config = 0; + + if (config) { + err = fuse_loop_cfg_verify(config); + if (err) + return err; + } else { + /* The caller does not care about parameters - use the default */ + config = fuse_loop_cfg_create(); + created_config = 1; + } - err = fuse_loop_cfg_verify(config); - if (err) - return err; memset(&mt, 0, sizeof(struct fuse_mt)); mt.se = se; @@ -372,6 +380,11 @@ int err; err = se->error; fuse_session_reset(se); + if (created_config) { + fuse_loop_cfg_destroy(config); + config = NULL; + } + return err; } @@ -380,12 +393,16 @@ FUSE_SYMVER("fuse_session_loop_mt_32", "fuse_session_loop_mt@FUSE_3.2") int fuse_session_loop_mt_32(struct fuse_session *se, struct fuse_loop_config_v1 *config_v1) { int err; + struct fuse_loop_config *config = NULL; - struct fuse_loop_config *config = fuse_loop_cfg_create(); - if (config == NULL) - return ENOMEM; + if (config_v1 != NULL) { + /* convert the given v1 config */ + config = fuse_loop_cfg_create(); + if (config == NULL) + return ENOMEM; - fuse_loop_cfg_convert(config, config_v1); + fuse_loop_cfg_convert(config, config_v1); + } err = fuse_session_loop_mt_312(se, config); |