[stgt] [PATCH V2 1/8] tgtd: fork logger before initializing llds

Roi Dayan roid at mellanox.com
Wed Jul 18 11:36:08 CEST 2012


Currently the logger is forked after LLDs are initialized/started, hence
file-descriptors opened during that initialization are duplicated during the
fork and remain open even when closed in the main thread.
The solution is to fork the logger before the LLDs are started.

Signed-off-by: Roi Dayan <roid at mellanox.com>
---
 usr/tgtd.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/usr/tgtd.c b/usr/tgtd.c
index cba2b66..f152715 100644
--- a/usr/tgtd.c
+++ b/usr/tgtd.c
@@ -552,12 +552,6 @@ int main(int argc, char **argv)
 
 	spare_args = optind < argc ? argv[optind] : NULL;
 
-	nr_lld = lld_init(spare_args);
-	if (!nr_lld) {
-		fprintf(stderr, "No available low level driver!\n");
-		exit(1);
-	}
-
 	err = ipc_init();
 	if (err)
 		exit(1);
@@ -565,15 +559,21 @@ int main(int argc, char **argv)
 	if (is_daemon && daemon(0,0))
 		exit(1);
 
-	err = oom_adjust();
+	err = log_init(program_name, LOG_SPACE_SIZE, is_daemon, is_debug);
 	if (err)
 		exit(1);
 
-	err = nr_file_adjust();
+	nr_lld = lld_init(spare_args);
+	if (!nr_lld) {
+		fprintf(stderr, "No available low level driver!\n");
+		exit(1);
+	}
+
+	err = oom_adjust();
 	if (err)
 		exit(1);
 
-	err = log_init(program_name, LOG_SPACE_SIZE, is_daemon, is_debug);
+	err = nr_file_adjust();
 	if (err)
 		exit(1);
 
-- 
1.7.8.2

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list