Subject: Re: bug#73199: soap-client; soap-invoke-internal is not thread-safe

From: Thomas Fitzsimmons <[email-masked]>
Date: Sat, 14 Sep 2024 10:06:47 -0400

Hi Michael,

Michael Albinus writes:

> Forward to debbugs
>
> From: Michael Albinus <[email-masked]>
> Subject: soap-client; soap-invoke-internal is not thread-safe
> To: Alexandru Harsanyi <[email-masked]>
> Date: Thu, 12 Sep 2024 15:57:45 +0200 (19 minutes, 24 seconds ago)
>
> In package debbugs, I try to use Emacs Lisp threads when retrieving SOAP
> data from the debbugs server. However, ocaasionally I run into the error
>
> --8<---------------cut here---------------start------------->8---
> (error "Attempt to accept output from process debbugs.gnu.org locked to thread #<thread 0xc288a0>")
> --8<---------------cut here---------------end--------------->8---
>
> My work around is to advice url-http-create-request
>
> --8<---------------cut here---------------start------------->8---
>   (advice-add
>    'url-http-create-request :around
>    (lambda (orig-fun)
>      "Set `url-http-attempt-keepalives' to nil."
>      (setq url-http-attempt-keepalives nil)
>      (funcall orig-fun))
>    '(name debbugs-advice))
> --8<---------------cut here---------------end--------------->8---
>
> However, it would be great if soap-invoke-internal could care.

I am not able to test Excorporate's usage of soap-client anymore to
check if a candidate patch would break anything.  I will ask on
emacs-devel if anyone wants to take over maintenance of Excorporate and
its dependencies.

A starting point for adding thread safety would be a minimal test case
that calls soap-invoke-internal against the debbugs server from multiple
different threads.  Are you able to extract such a test case?

If the resulting patch is obviously safe for single-threaded usage by
Excorporate, then I could push it to soap-client.el.

Thanks,
Thomas