guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Making HTTP requests over TLS from multiple threads


From: Christopher Baines
Subject: Making HTTP requests over TLS from multiple threads
Date: Thu, 18 Mar 2021 09:27:35 +0000
User-agent: mu4e 1.4.15; emacs 27.1

Hey,

I think I'm having some issues with making HTTP requests over TLS with
Guile, I'm using the open-socket-for-uri procedure from (web client) for
the port.

I've attached a small test program that reliably reproduces the issue
for me, and I've included the output I typically get below [1].

At the start, a few requests are made from a single thread, and that
works fine. As soon as there are two threads though, some uses of the
port raise an error/again exception, at which point the program waits a
second and retries (I guess that's sensible). Other errors that don't
look more serious then happen.

I've read the GnuTLS and GnuTLS Guile documentation, but the only things
I've found that look relevant are suggestions in the GnuTLS
documentation that using multiple threads should be OK.

I have tried copying large amounts of the relevant Guile procedures so
that I can access and tweak the GnuTLS related code, but that didn't
reveal anything obvious to me at least.

One other interesting thing is that if the different threads connect to
different sites, that doesn't seem to break.

Could there be some shared state somewhere for the connections that's
leading to things going wrong?

Thanks,

Chris

Attachment: threaded-https-connections-test.scm
Description: Text document

1:
thread 1 making request
thread 1 making request
thread 1 making request
thread 1 making request
thread 1 making request
thread 1 making request

trying concurrent threads

thread 1 making request
thread 2 making request
error/again
error/again
error/again
thread 1: exception: gnutls-error (#<gnutls-error-enum Error in the push 
function.> write_to_session_record_port)

Backtrace:
In srfi/srfi-1.scm:
    634:9 12 (for-each #<procedure 7f70c6cf0e60 at ice-9/eval.scm:3…> …)
In ice-9/boot-9.scm:
  1736:10 11 (with-exception-handler _ _ #:unwind? _ # _)
In ice-9/eval.scm:
    619:8 10 (_ #(#(#(#(#(#<directory (guile-user) 7f70…>) …) …) …) …))
    619:8  9 (_ #(#(#(#(#(#(#<directory (guile-user)…>) …) …) …) …) …))
In srfi/srfi-1.scm:
    634:9  8 (for-each #<procedure 7f70c6cf0260 at ice-9/eval.scm:3…> …)
In unknown file:
           7 (put-bytevector #<output: string 7f70c4c105b0> #vu8(0 …) …)
In web/http.scm:
  2029:35  6 (flush)
In unknown file:
           5 (put-char #<input-output: string 7f70c4c10620> #\nul)
In web/client.scm:
    267:8  4 (write! #vu8(0 53 55 97 13 10 0 0 0 0 0 0 0 0 0 0 0 0 …) …)
In unknown file:
           3 (put-bytevector #<input-output: string 7f70c4c10690> # 0 …)
In ice-9/boot-9.scm:
  1669:16  2 (raise-exception _ #:continuable? _)
  1764:13  1 (_ #<&compound-exception components: (#<&error> #<&irri…>)
In unknown file:
           0 (backtrace #<undefined>)

In srfi/srfi-1.scm:
    634:9 11 (for-each #<procedure 7f70c6cf0e60 at ice-9/eval.scm:3…> …)
In ice-9/boot-9.scm:
  1736:10 10 (with-exception-handler _ _ #:unwind? _ # _)
In ice-9/eval.scm:
    619:8  9 (_ #(#(#(#(#(#<directory (guile-user) 7f70…>) …) …) …) …))
    619:8  8 (_ #(#(#(#(#(#(#<directory (guile-user)…>) …) …) …) …) …))
In srfi/srfi-1.scm:
    634:9  7 (for-each #<procedure 7f70c6cf0260 at ice-9/eval.scm:3…> …)
In unknown file:
           6 (put-bytevector #<output: string 7f70c4c105b0> #vu8(0 …) …)
In web/http.scm:
  2029:35  5 (flush)
In unknown file:
           4 (put-char #<input-output: string 7f70c4c10620> #\nul)
In web/client.scm:
    267:8  3 (write! _ _ 1024)
In unknown file:
           2 (put-bytevector #<input-output: string 7f70c4c10690> # 0 …)
In ice-9/boot-9.scm:
  1669:16  1 (raise-exception _ #:continuable? _)
  1669:16  0 (raise-exception _ #:continuable? _)
ice-9/boot-9.scm:1669:16: In procedure raise-exception:
Throw to key `gnutls-error' with args `(#<gnutls-error-enum Error in the push 
function.> write_to_session_record_port)'.
warning: SIGPIPE
thread 2 making request
In procedure write_to_session_record_port: Wrong type argument in position 1: 
#<finalized smob 7f70c56c3fe0>

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]