From patchwork Tue Jan 3 16:20:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seija Kijin X-Patchwork-Id: 13087650 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDF70C54EBC for ; Tue, 3 Jan 2023 16:21:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238009AbjACQUz (ORCPT ); Tue, 3 Jan 2023 11:20:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237958AbjACQUY (ORCPT ); Tue, 3 Jan 2023 11:20:24 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9F3860C9 for ; Tue, 3 Jan 2023 08:20:23 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id fm16-20020a05600c0c1000b003d96fb976efso21496263wmb.3 for ; Tue, 03 Jan 2023 08:20:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=b0pKBDD2cFEcMLMyG95NYGpS2hFKDXbsupSJgR2jDfM=; b=gi1qc8g8243kXm+HK1ITsOeT5/aNSdB3FuQ+2yVWp8CaCeDxW3LNNaqlU8t4Ni+97v u8gXHAqTk8Ai1pNUptL29Dm6Fs7PIp9XLUKCsi+HIgKFBqyfShSMxMHkw+E/V4Oqt/S8 7cyVzQLgiaEuwDPQvXpwrrFCJ4J+cvVlH94FxsfWpWMW5WBh24jfwqZ3RNkAoA1R74Cp tb38FaH74J9Zma/x2KRFIUc0QdiZeX9JfdfSGULBYZCFSWAVm+e5eB7iDPhMEXlO/fIR cvoYk0daYiF8W9AN9XK2nVIFBh9B5dijz1thDwCI16goqnvvTGh60kBZLRv9lwZFox4A CLbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b0pKBDD2cFEcMLMyG95NYGpS2hFKDXbsupSJgR2jDfM=; b=hgqmceKA6tbsBv5nLLefV8d0xOVgLSssE/oJ6KUWrkgWVwgiHRZ7EDN2f7ku12Q/f8 3mETIlmtelOQOeDo5PM8N6wc5xSGH0oFLpw57BDx6dR8QlXDsbT+aCyTm8swxN96rtfh YVPjLxX53tEMb4159VdRxqK5GZu3on/6PZFFyh3juavhNzLlEcHNwobxZnUWxg4lKfsS CrjEbhb/x/8V51GB/z0giHDCfzvCqPvVdRynb8H2kAt8J/2L7tfPVwXs1gb+6sFcS5Rn V5Sy2Qy5sqB0sBPi2VGuKYI4mSur4z8ofepmulL/VrDindGbRQuieHW8ASRpFg1vgrgy c5Xg== X-Gm-Message-State: AFqh2kr1AKZBc17XhuzNHjTflYApVtqZAT3qWQf+ED2FnT8gtYR05xYO Gj9aYocnArmzC4CPWV8PSY3mgFiMixo= X-Google-Smtp-Source: AMrXdXtBx5S1oyaNimYAYgXS81yAJGJz8RWndr/Yd9fXggIKSAaeYxpZEgRakvZFsCX9fRB4vbolcA== X-Received: by 2002:a05:600c:1e1e:b0:3d2:3b4d:d619 with SMTP id ay30-20020a05600c1e1e00b003d23b4dd619mr31603683wmb.15.1672762822284; Tue, 03 Jan 2023 08:20:22 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id e8-20020a05600c13c800b003cfd58409desm45671836wmg.13.2023.01.03.08.20.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 08:20:22 -0800 (PST) Message-Id: <6f89b1206418771b5a7c9a5a79b91b0f21b516df.1672762819.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 03 Jan 2023 16:20:18 +0000 Subject: [PATCH v13 1/2] win32: prepare pthread.c for change by formatting Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Johannes Sixt , =?utf-8?b?UmVuw6k=?= Scharfe , Rose <83477269+AtariDreams@users.noreply.github.com>, Seija Kijin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Seija Kijin From: Seija Kijin File has been formatted to meet coding guidelines. Signed-off-by: Seija Kijin --- compat/win32/pthread.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/compat/win32/pthread.c b/compat/win32/pthread.c index 2e7eead42cb..cf53bc61d82 100644 --- a/compat/win32/pthread.c +++ b/compat/win32/pthread.c @@ -22,12 +22,12 @@ static unsigned __stdcall win32_start_routine(void *arg) } int pthread_create(pthread_t *thread, const void *unused, - void *(*start_routine)(void*), void *arg) + void *(*start_routine)(void *), void *arg) { thread->arg = arg; thread->start_routine = start_routine; - thread->handle = (HANDLE) - _beginthreadex(NULL, 0, win32_start_routine, thread, 0, NULL); + thread->handle = (HANDLE)_beginthreadex(NULL, 0, win32_start_routine, + thread, 0, NULL); if (!thread->handle) return errno; @@ -39,14 +39,14 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr) { DWORD result = WaitForSingleObject(thread->handle, INFINITE); switch (result) { - case WAIT_OBJECT_0: - if (value_ptr) - *value_ptr = thread->arg; - return 0; - case WAIT_ABANDONED: - return EINVAL; - default: - return err_win_to_posix(GetLastError()); + case WAIT_OBJECT_0: + if (value_ptr) + *value_ptr = thread->arg; + return 0; + case WAIT_ABANDONED: + return EINVAL; + default: + return err_win_to_posix(GetLastError()); } } From patchwork Tue Jan 3 16:20:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seija Kijin X-Patchwork-Id: 13087651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C27E4C53210 for ; Tue, 3 Jan 2023 16:21:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237880AbjACQUw (ORCPT ); Tue, 3 Jan 2023 11:20:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238006AbjACQU0 (ORCPT ); Tue, 3 Jan 2023 11:20:26 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A873C10B49 for ; Tue, 3 Jan 2023 08:20:24 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id k22-20020a05600c1c9600b003d1ee3a6289so23706188wms.2 for ; Tue, 03 Jan 2023 08:20:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=LALDJalj/jWAGbQui/a9xb6Cxuxb09zTIcklilPVUu8=; b=MwT3x5Ets76zXmagbBR68P649JptyvUC0xa9NG9j9+djDREGZR6OPdz6EpSIDIOMnZ BV35tXGqn9+Y1xomIFYy+AN6i+dRirY2g3JyTpZU9bMmkbRRwksCZSosMAQRJPekyk65 YwyvBUNCg6y8X9qcRrq0DWHrnn0VyON2XIacyfhHFIDJru9gT4aAbv4VhUt8eRvyC9+U U1BBKPMxhcaQSYQ+Y5lzHE3/dHCGzgJaALmDohbb5tjTNJofKSQsNjWWb2g/a5ceb8ls BklvHRyd12KinM22774lM+d9GeUOJjIy4ia4Y2RGTqbDvYXsu4CzDQRe3c20aikjeDpI GrYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LALDJalj/jWAGbQui/a9xb6Cxuxb09zTIcklilPVUu8=; b=Dc+nNJInkTEc+/SVfjO//LmxSVcv0wLLboqyEZgqAhFq1q6p5ssNJ/Y+AWp6PSK+zZ V99nceeJfRE+U4d6y5p5FB1Ce1VwhXH1qpQO4J8x0UZRHk659Y+g9xMOBWOwc0ldzsve 2RQznBre+NiIrkjnY+0YnMHIWbriBR4Gx9ztcfJw1JtYZgLv6TWnCd2MoJ+y0Jc7DpY3 ey1BhjRWxXM6ToH2hZkjg02sK9LelVq6XGAFsRzlna7uIqNblwoeR8T2g4EP9wkpNu1c RD3hGoFuYv70gF/3LnoCoITGWk9m+GwfmD9r8Ogmow3EmRfVcMAokMkLLepZFsI7VssY VNVw== X-Gm-Message-State: AFqh2kpq1W0HO01UJVA6yHBcr8YKRKpx0d6x5MDOsPNA3c/frxKopHNi l7e3cBgLw6NLPGUc8KipAV0eXaiHqDw= X-Google-Smtp-Source: AMrXdXvHJO1BF70er1wY/43ZX6V86BxpypwZuPvAJiunYf3nJku/DAivRL3/bbrOQ0Rz7hZQGJZoDQ== X-Received: by 2002:a05:600c:3b95:b0:3d9:baf2:315b with SMTP id n21-20020a05600c3b9500b003d9baf2315bmr3966036wms.11.1672762823009; Tue, 03 Jan 2023 08:20:23 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l42-20020a05600c1d2a00b003cfbbd54178sm70214766wms.2.2023.01.03.08.20.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 08:20:22 -0800 (PST) Message-Id: In-Reply-To: References: Date: Tue, 03 Jan 2023 16:20:19 +0000 Subject: [PATCH v13 2/2] win32: close handles of threads that have been joined Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Johannes Sixt , =?utf-8?b?UmVuw6k=?= Scharfe , Rose <83477269+AtariDreams@users.noreply.github.com>, Seija Kijin Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Seija Kijin From: Seija Kijin After the thread terminates, the handle to the original thread should be closed. This change makes win32_pthread_join POSIX compliant. Signed-off-by: Seija Kijin --- compat/win32/pthread.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compat/win32/pthread.c b/compat/win32/pthread.c index cf53bc61d82..85f8f7920ce 100644 --- a/compat/win32/pthread.c +++ b/compat/win32/pthread.c @@ -42,10 +42,13 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr) case WAIT_OBJECT_0: if (value_ptr) *value_ptr = thread->arg; + CloseHandle(thread->handle); return 0; case WAIT_ABANDONED: + CloseHandle(thread->handle); return EINVAL; default: + /* the wait failed, so do not detach */ return err_win_to_posix(GetLastError()); } }