From: yangyun <yangyun50@huawei.com>
Date: Tue, 4 Jun 2024 12:57:14 +0000 (+0800)
Subject: fix useless fuse_init_intr_signal in high-level api
X-Git-Tag: fuse-3.17.1-rc0~109
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=8bd873cbcc6037655c0a6cf2f63fe1f8f13c5a5e;p=qemu-gpiodev%2Flibfuse.git

fix useless fuse_init_intr_signal in high-level api

The code `fuse_init_intr_signal` in `_fuse_new_317` is useless
since commit 8ee553dac ("fuse_new(): don't accept options that
don't make sense for end-users") has remove the conf.intr option
for end-users. The conf.intr is always zero (i.e., disabled) here.

Move `fuse_init_intr_signal` after the user-defined `init()` function,
so that conf.intr and conf.intr_signal has been configured by the user.
---

diff --git a/lib/fuse.c b/lib/fuse.c
index 4f06da7..35a807b 100644
--- a/lib/fuse.c
+++ b/lib/fuse.c
@@ -2604,6 +2604,8 @@ void fuse_fs_init(struct fuse_fs *fs, struct fuse_conn_info *conn,
 		fs->user_data = fs->op.init(conn, cfg);
 }
 
+static int fuse_init_intr_signal(int signum, int *installed);
+
 static void fuse_lib_init(void *data, struct fuse_conn_info *conn)
 {
 	struct fuse *f = (struct fuse *) data;
@@ -2613,9 +2615,14 @@ static void fuse_lib_init(void *data, struct fuse_conn_info *conn)
 		conn->want |= FUSE_CAP_EXPORT_SUPPORT;
 	fuse_fs_init(f->fs, conn, &f->conf);
 
-	/* Disable the receiving and processing of FUSE_INTERRUPT requests */
-	if (!f->conf.intr)
+	if (f->conf.intr) {
+		if (fuse_init_intr_signal(f->conf.intr_signal,
+				&f->intr_installed) == -1)
+			fuse_log(FUSE_LOG_ERR, "fuse: failed to init interrupt signal\n");
+	} else {
+		/* Disable the receiving and processing of FUSE_INTERRUPT requests */
 		conn->no_interrupt = 1;
+	}
 }
 
 void fuse_fs_destroy(struct fuse_fs *fs)
@@ -5020,12 +5027,6 @@ struct fuse *_fuse_new_317(struct fuse_args *args,
 
 	strcpy(root->inline_name, "/");
 	root->name = root->inline_name;
-
-	if (f->conf.intr &&
-	    fuse_init_intr_signal(f->conf.intr_signal,
-				  &f->intr_installed) == -1)
-		goto out_free_root;
-
 	root->parent = NULL;
 	root->nodeid = FUSE_ROOT_ID;
 	inc_nlookup(root);
@@ -5033,8 +5034,6 @@ struct fuse *_fuse_new_317(struct fuse_args *args,
 
 	return f;
 
-out_free_root:
-	free(root);
 out_free_id_table:
 	free(f->id_table.array);
 out_free_name_table: