From patchwork Mon Nov 30 19:00:48 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5826 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:91c9:10b0:11b:d6c:f273 with SMTP id tl9-n1csp13502006lad; Mon, 30 Nov 2026 11:01:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErGMtrq7OeQ2KwdoQPtNVxz37yzHjubbo9sWDkSz+IcP4a0RxMRHOEY4pBalBg0K8Ld924jyM1iQ7rg=@openvpn.net X-Received: by 2002:a05:7300:1909:b0:383:f646:9feb with SMTP id 5a478bee46e88-3856c4b8304mr50201141eec.2.1796065269286; Mon, 30 Nov 2026 11:01:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1796065269; cv=none; d=google.com; s=arc-20260327; b=etpDzXHPesDaI0jzs8eRTpSt3M8rottACaK8ZJYJtopRQ2AzGQivprCb+HJC3zeRsw yLYKSxbc+ZDjtI33HAFKcAdRh+c4wyFWhxvY4pWDRiSG3uiSiqamIzEiaWlashK1HUl4 KR41RPp05dexwOIg0USFhCiwn5uVjbp0jlm2tt4G5icnhJFgnlh4hWMpAwbIcqkNMJlU sus4ygYtJzdhgNFO5gseDPFPfBTL+pXfbgT3Omw5AZvMBY8XIKvbuXDoGbVD3OqxGGYu jhT8CpiL/O/ez7HQ++FZWzpf0aHnWmNoHrFt/3kWA7lBAxM+ytr2FuiMJbrJizfeo/v2 6fGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=xem+BU6Z+pMWq4A5mWZPk3vl9szvT7CTqGlBqX6You0=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=P70Jh4Oj855Tkqn5jOJQ1OUVRtuSlW5bZxBSMxmdAa9yHk92tKyN6n9ToJhjNWpIzo AaTqICygmHg9+whJTzpRO7QA7r0IFIGRZ8//+tBeDmQMOYNwVvagAAiJt9p7pFh5d7KC UPPbYvO+gOeQ1/SRVGdIt/sMz83QVaHnvuKczVkfiHMnfDxuXN89U+YyEIGYmExZmybM U7L/ooW8K6MOrfleHvvNvlDZWWFQVzNYre/B9ViuddtoIM1JB9vIfWR9BS6cefb1ckup wMuBvtJgyYGSr2VeL9t8HyDsn5hbEMIyAF/KRZtxacc7YrUlNyviTc8LbVO3zro22QCF FXtg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=h8Ebip96; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=PqKMZTJS; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=X4t+gYxv; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5a478bee46e88-385679bcccdsi86198194eec.41.2026.11.30.11.01.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 Nov 2026 11:01:09 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=h8Ebip96; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=PqKMZTJS; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=X4t+gYxv; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=xem+BU6Z+pMWq4A5mWZPk3vl9szvT7CTqGlBqX6You0=; b=h8Ebip96iGmQFL RhOkUuQ2iekQQw1GDutEMGpaqXLIpo3SJfO4Fv3JdFHr/Ug8jOZZ4lB20jHYH7xK9xDgqiJawbqii tUPOBNb5r4cXRz1mNqc24RXjk3K9XPLRA2Xv+UHkEvY/ScgVcdQHB+onowxJmtuOjSkPUNxjSg8q1 Y8A=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xY6cb-000000000K1-20E4; Mon, 30 Nov 2026 19:01:05 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xY6cZ-000000000Jv-3NPd for openvpn-devel@lists.sourceforge.net; Mon, 30 Nov 2026 19:01:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=v0pgtfVVaiMwi5V+QGwie9A2XlkcLzjIyzHLLxfC+qo=; b=PqKMZTJSLLrgc3YwidfwfPKx++ Td7BqSVG+0JdsuN0xQ33NNnGRqN/NgAwhgiKFharytkI046GQsfgENkK9GZTNDXQHzv2FwUCj8cZ9 6HE6gpKpDyK2sgwo+0WjjCJSEh5ju+fb40uYRNR0HONz2y8TlLwPC3iL4c1HvfbYrwzw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=v0pgtfVVaiMwi5V+QGwie9A2XlkcLzjIyzHLLxfC+qo=; b=X4t+gYxvpia4SvnCWv4YHSZsxs Bbb1LCOz7Cfi/5+4O7ohzJI7WIxj1/NT4QBphTtxUKAO5QjrW1hQPVm1fmBva4X5GwD9imfs75UHZ 5ToJjiCoEcNHOEaO6SdywPMaxWB2CkUhGG9hHEzpFtVIFhfDTTbEQit9TGAC2/9OjPCE=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xY6cX-0000000083T-2xeF for openvpn-devel@lists.sourceforge.net; Mon, 30 Nov 2026 19:01:03 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 6AUJ0sMU007663 for ; Mon, 30 Nov 2026 20:00:54 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 6AUJ0sh3007662 for openvpn-devel@lists.sourceforge.net; Mon, 30 Nov 2026 20:00:54 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Mon, 30 Nov 2026 20:00:48 +0100 Message-ID: <20261130190054.7645-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Gianmarco De Gregori In server mode the management listen socket stays in the persistent event set after a client is accepted. A second connection queued on it keeps it readable, so every event wait returns immediately fo [...] Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1xY6cX-0000000083T-2xeF Subject: [Openvpn-devel] [PATCH v3] manage: stop polling the listen socket while a client is connected X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1883310936218967465 X-GMAIL-MSGID: 1883310936218967465 From: Gianmarco De Gregori In server mode the management listen socket stays in the persistent event set after a client is accepted. A second connection queued on it keeps it readable, so every event wait returns immediately for the management, management_io() finds nothing to do on the client socket, and the server spins at 100% CPU while timers starve. Remove sd_top from the event set on accept; it is re-added when the state goes back to MS_LISTEN. Reset the cached state on removal, so the next update registers the right socket even after an accept or close in a standalone management loop, and skip the removal when nothing is registered. Trac: #681 Change-Id: I06302e82cdc7c98503430500daa4ec95f5ce961f Signed-off-by: Gianmarco De Gregori Acked-by: Razvan Cojocaru Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2212 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2212 This mail reflects revision 3 of this Change. Acked-by according to Gerrit (reflected above): Razvan Cojocaru diff --git a/src/openvpn/manage.c b/src/openvpn/manage.c index bada1ae..a3e8be6a 100644 --- a/src/openvpn/manage.c +++ b/src/openvpn/manage.c @@ -344,6 +344,17 @@ #endif } +#ifndef _WIN32 +static void +man_delete_event(struct management *man, const socket_descriptor_t sd) +{ + if (man->persist.callback.delete_event) + { + (*man->persist.callback.delete_event)(man->persist.callback.arg, sd); + } +} +#endif + static void man_close_socket(struct management *man, const socket_descriptor_t sd) { @@ -352,10 +363,7 @@ * Windows doesn't need this because the ne32 event is permanently * enabled at struct management scope. */ - if (man->persist.callback.delete_event) - { - (*man->persist.callback.delete_event)(man->persist.callback.arg, sd); - } + man_delete_event(man, sd); #endif openvpn_close_socket(sd); } @@ -2070,6 +2078,8 @@ { #ifdef _WIN32 man_stop_ne32(man); +#else + man_delete_event(man, man->connection.sd_top); #endif } diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index 900b5a3..4113f26 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -4057,9 +4057,10 @@ management_delete_event(void *arg, event_t event) { struct multi_context *m = (struct multi_context *)arg; - if (m->multi_io) + if (m->multi_io && m->multi_io->management_persist_flags) { multi_io_delete_event(m->multi_io, event); + m->multi_io->management_persist_flags = 0; } }