From: Michael Albinus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: AlexHarsanyi@gmail.com, fitzsim@fitzsim.org,
monnier@iro.umontreal.ca, 73199@debbugs.gnu.org
Subject: bug#73199: url-retrieve is not thread-safe
Date: Mon, 30 Sep 2024 18:42:55 +0200 [thread overview]
Message-ID: <87seth9jow.fsf@gmx.de> (raw)
In-Reply-To: <86frph2lqd.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 30 Sep 2024 18:40:42 +0300")
[-- Attachment #1: Type: text/plain, Size: 132 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
>> Comments?
>
> ENOPATCH
Oops, sorry. I've appended the vc-dir buffer, not the vc-diff ...
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 2890 bytes --]
diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index 184c1278072..019ba2d7e57 100644
--- 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 port))))
+ (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 port))))
+ (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)))
next prev parent reply other threads:[~2024-09-30 16:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-12 14:20 bug#73199: soap-client; soap-invoke-internal is not thread-safe Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-14 14:06 ` Thomas Fitzsimmons
2024-09-20 9:58 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
[not found] ` <87wmit9nvh.fsf_-_@gmx.de>
2024-09-30 15:40 ` bug#73199: url-retrieve " Eli Zaretskii
2024-09-30 16:42 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-09-30 17:38 ` Eli Zaretskii
2024-10-02 16:34 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-02 18:30 ` Eli Zaretskii
2024-10-10 11:29 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-10 13:10 ` Eli Zaretskii
2024-10-11 10:44 ` Michael Albinus via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87seth9jow.fsf@gmx.de \
--to=bug-gnu-emacs@gnu.org \
--cc=73199@debbugs.gnu.org \
--cc=AlexHarsanyi@gmail.com \
--cc=eliz@gnu.org \
--cc=fitzsim@fitzsim.org \
--cc=michael.albinus@gmx.de \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).