unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Ryan Raymond <rjraymond@oakland.edu>
To: guile-devel@gnu.org
Subject: Non-blocking web server
Date: Sun, 24 Mar 2024 15:41:32 -0400	[thread overview]
Message-ID: <CAGvJ-HQQZ++7g36ti_X2TB_1iMMDoL70CNzMstwZAu+QZ53tmQ@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 919 bytes --]

Hello, all.
I was able to build a non-blocking web-server using network sockets.
However, the existing guile web/server.scm implementation is
single-threaded and therefore blocking, which is sub-optimal for some
use-cases.

I suggest we slightly modify the server logic to have an optional
#:blocking? [bool] parameter which would enable behavior in line with the
following excerpt from my own code. Obviously some changes would be made to
methodology and code style, but you get the picture.

(define (listen sock)
  (let* (
    (client-connection (accept sock))
    (client-details (cdr client-connection))
    (client (car client-connection)))
    (begin-thread
      (sigaction SIGPIPE SIG_IGN)
      (handle client)
      (close client))
    ))

This shouldn't cause any backwards-compatibility issues since it's
optional, but the specifics of web/server.scm might cause problems.
Let me know what you think!
Ryan

[-- Attachment #2: Type: text/html, Size: 1099 bytes --]

             reply	other threads:[~2024-03-24 19:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-24 19:41 Ryan Raymond [this message]
2024-03-25  5:31 ` Non-blocking web server tomas
2024-03-25  9:24 ` Nala Ginrut
2024-03-25 10:44 ` Maxime Devos

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/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGvJ-HQQZ++7g36ti_X2TB_1iMMDoL70CNzMstwZAu+QZ53tmQ@mail.gmail.com \
    --to=rjraymond@oakland.edu \
    --cc=guile-devel@gnu.org \
    /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.
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).