From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#73199: url-retrieve is not thread-safe Date: Mon, 30 Sep 2024 18:42:55 +0200 Message-ID: <87seth9jow.fsf@gmx.de> References: <87cyl9j6ng.fsf@gmx.de> <875xqqk5oq.fsf@gmx.de> <87wmit9nvh.fsf_-_@gmx.de> <86frph2lqd.fsf@gnu.org> Reply-To: Michael Albinus Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16151"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: AlexHarsanyi@gmail.com, fitzsim@fitzsim.org, monnier@iro.umontreal.ca, 73199@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 30 18:50:06 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1svJb4-00043b-Gw for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 30 Sep 2024 18:50:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1svJan-0007Ad-3g; Mon, 30 Sep 2024 12:49:49 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1svJak-00072D-Pj for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2024 12:49:46 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1svJak-0007QD-4R for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2024 12:49:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=vjW3lY80LFnMxjeiiJkrQg/yRDzOofXbjGB4/FejYcM=; b=UngGC4S6MF9zY7XPxRgDFP3clPRRJPEz7R+fe+unQWu80NGNkV3kOSwyDb1MsWdMsOKcaLfrH1wQaOq86cnYlexBJHzhhq2NMTKtXPQn+uPrmmEFQAKXgx+bZr+I9hPnFEJPHURovs4G1D/XUyqwseY4vQN81QwAdruFuwW3k5GtCS0Ee236QODYxJRiYZyPDw8wY+B8vwFulAic7uC+sZqs/N6MqVC9nhRcLyIkJnCDVlqlYUkuAp9COzqfAyvtXyk5i3L8lmbQoAeSN68LE/2ABXNPQhof4WjRx9fv8O2FPfnEI5PXBnEo+ZRTWbxOmvc9ikoVFjKJaaX+3WvFsg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1svJbF-0003m9-ML for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2024 12:50:17 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Sep 2024 16:50:15 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73199 X-GNU-PR-Package: emacs Original-Received: via spool by 73199-submit@debbugs.gnu.org id=B73199.172771494713783 (code B ref 73199); Mon, 30 Sep 2024 16:50:15 +0000 Original-Received: (at 73199) by debbugs.gnu.org; 30 Sep 2024 16:49:07 +0000 Original-Received: from localhost ([127.0.0.1]:45825 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1svJa6-0003aF-I6 for submit@debbugs.gnu.org; Mon, 30 Sep 2024 12:49:06 -0400 Original-Received: from mout.gmx.net ([212.227.17.21]:57117) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1svJa3-0003Yo-EH for 73199@debbugs.gnu.org; Mon, 30 Sep 2024 12:49:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1727714904; x=1728319704; i=michael.albinus@gmx.de; bh=vjW3lY80LFnMxjeiiJkrQg/yRDzOofXbjGB4/FejYcM=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=caYHjD8EpoOjOnJSCesOhwsBVUSez60rM+R7t5fqwlSIZaNdZFak/k7WLSqmPQR4 rR09v7LWcJMWVhRBUfv+sSz3br0UHdiAfhwbSyAzsBs/ZzAMeJWCAvpit7/Pk/P6R jd0XcRbQuo2AkuTw4ES3vf7Vdho+tDz/yOxgv4VQ+Twwt4s4HfloXxkNLeQIZSYTn +14KWayuszJwonBSuK/LNTVS7YNnvgOrZ0EqCcB1UWHH9udIAAyLIdtvjHiezTxhF m2YgfENyq3NwKxkYen+rKRIBuN9oJhebL8Ya82hEu0Gf2RkwoOaZO5OBa4NgE1SsY +glgcAsDZzWqCiwczQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Original-Received: from gandalf.gmx.de ([185.89.38.155]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N95eJ-1rrx1o1ggh-00zmtX; Mon, 30 Sep 2024 18:42:59 +0200 In-Reply-To: <86frph2lqd.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 30 Sep 2024 18:40:42 +0300") X-Provags-ID: V03:K1:IwQ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00AAjhrqyjmz5k X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:292729 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> Comments? > > ENOPATCH Oops, sorry. I've appended the vc-dir buffer, not the vc-diff ... --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Transfer-Encoding: quoted-printable diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index 184c1278072..019ba2d7e57 100644 =2D-- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -74,7 +74,9 @@ url-http-proxy-basic-auth-storage (defvar url-http-open-connections (make-hash-table :test 'equal :size 17) - "A hash table of all open network connections.") + "A hash table of all open network connections. +If Emacs is compiled with thread support, the key is a list `(host port +thread)'. Otherwise, it is a cons cell `(host . port)'.") (defvar url-http-version "1.1" "What version of HTTP we advertise, as a string. @@ -154,26 +156,33 @@ url-http-debug (apply #'url-debug 'http args)) (defun url-http-mark-connection-as-busy (host port proc) - (url-http-debug "Marking connection as busy: %s:%d %S" host port proc) - (set-process-query-on-exit-flag proc t) - (puthash (cons host port) - (delq proc (gethash (cons host port) url-http-open-connections)) - url-http-open-connections) - proc) + (let ((key (if main-thread + (list host port (funcall 'current-thread)) (cons host po= rt)))) + (url-http-debug "Marking connection as busy: %s:%d %S" host port proc= ) + (set-process-query-on-exit-flag proc t) + (puthash key + (delq proc (gethash key url-http-open-connections)) + url-http-open-connections) + proc)) (defun url-http-mark-connection-as-free (host port proc) - (url-http-debug "Marking connection as free: %s:%d %S" host port proc) - (when (memq (process-status proc) '(open run connect)) - (set-process-buffer proc nil) - (set-process-sentinel proc 'url-http-idle-sentinel) - (set-process-query-on-exit-flag proc nil) - (puthash (cons host port) - (cons proc (gethash (cons host port) url-http-open-connections)) - url-http-open-connections)) - nil) + (let ((key (if main-thread + (list host port (funcall 'current-thread)) (cons host po= rt)))) + (url-http-debug "Marking connection as free: %s:%d %S" host port proc= ) + (when (memq (process-status proc) '(open run connect)) + (set-process-buffer proc nil) + (set-process-sentinel proc 'url-http-idle-sentinel) + (set-process-query-on-exit-flag proc nil) + (puthash key + (cons proc (gethash key url-http-open-connections)) + url-http-open-connections)) + nil)) (defun url-http-find-free-connection (host port &optional gateway-method) - (let ((conns (gethash (cons host port) url-http-open-connections)) + (let ((conns (gethash + (if main-thread + (list host port (funcall 'current-thread)) (cons host= port)) + url-http-open-connections)) (connection nil)) (while (and conns (not connection)) (if (not (memq (process-status (car conns)) '(run open connect))) --=-=-=--