From patchwork Wed Feb 12 13:14:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Castanho X-Patchwork-Id: 1236852 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-109567-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha1 header.s=default header.b=ESNusfPU; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Hg902s83z9sRJ for ; Thu, 13 Feb 2020 00:14:44 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; q=dns; s= default; b=Whm2f0aYBwBz6Tl3f0itGxkCdklDBtvPah9McwlrlXnW7gZJWvKs0 F1klnLcuMEp6QVwdPxMY7v/lrfj3YWryohOtj28ujYuZqeabtMjt2+21iFinHzIH TRlVmuBnfXeahnblzekARkyPdwf1sqr53tZI3PwQspaTJlwUJEw41c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; s=default; bh=xqvnC2Xb1Cjwj21ukXUPu+4gQ28=; b=ESNusfPUYtO6Boq5yba6zBIcSMJ8 FPcif6pSsICpaPjy21LUvU6GTA96gSqyS8Ge0yJbSf17zPJtPY5p5byJ/kDuweWR 7mdtSvisvGlxX9eOPVRw9ZGAaPfogLHC052W2M0fiAOVhC1H1DhbE4wEXO8rqdWV B+0qggJOJGOeQrM= Received: (qmail 43473 invoked by alias); 12 Feb 2020 13:14:37 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 42634 invoked by uid 89); 12 Feb 2020 13:14:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com From: Matheus Castanho To: fw@deneb.enyo.de Cc: libc-alpha@sourceware.org Subject: [PATCH] sunrpc: Properly clean up if tst-udp-timeout fails Date: Wed, 12 Feb 2020 10:14:23 -0300 Message-Id: <20200212131423.27742-1-msc@linux.ibm.com> In-Reply-To: <87a75ut9za.fsf@mid.deneb.enyo.de> References: <87a75ut9za.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 Hi Florian, I have experimented with the options you listed above, but will probably leave them for a future patch, as a generic solution will likely require more careful consideration. For the moment I dropped the extra TEST_VERIFY macro and fixed this single test using the atexit() approach you pointed. I think it is preferable to removing the TEST_VERIFY_EXIT calls, as without them we would have to run the entire test (17-25 secs) even if an error ocurred in the beginning. Also, I don't think we need to add more complexity to this test (e.g. moving the client to a subprocess), as it already has a lot going on, so I opted for this simpler approach. The updated patch is below. Thanks, Matheus Castanho --- 8< --- The macro TEST_VERIFY_EXIT is used several times on sunrpc/tst-udp-timeout to exit the test if a condition evaluates to false. The side effect is that the code to terminate the RPC server process is not executed when the program calls exit(), so that sub-process stays alive. This commit registers a clean up function with atexit() to kill the server process before exiting the main program. --- sunrpc/tst-udp-timeout.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sunrpc/tst-udp-timeout.c b/sunrpc/tst-udp-timeout.c index 8d45365b23..de2fc3bf8c 100644 --- a/sunrpc/tst-udp-timeout.c +++ b/sunrpc/tst-udp-timeout.c @@ -29,6 +29,9 @@ #include #include #include +#include + +pid_t pid; /* Test data serialization and deserialization. */ @@ -177,6 +180,14 @@ server_dispatch (struct svc_req *request, SVCXPRT *transport) } } +/* Function to be called before exit() to make sure the + * server process is properly killed. */ +static void +kill_server (void) +{ + kill(pid, SIGTERM); +} + /* Implementation of the test client. */ static struct test_response @@ -381,12 +392,13 @@ do_test (void) TEST_VERIFY_EXIT (transport != NULL); TEST_VERIFY (svc_register (transport, PROGNUM, VERSNUM, server_dispatch, 0)); - pid_t pid = xfork (); + pid = xfork (); if (pid == 0) { svc_run (); FAIL_EXIT1 ("supposed to be unreachable"); } + atexit(kill_server); test_udp_server (transport->xp_port); int status;