From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ryan Raymond Newsgroups: gmane.lisp.guile.devel Subject: Non-blocking web server Date: Sun, 24 Mar 2024 15:41:32 -0400 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="0000000000002b8ebe06146d3f42" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29032"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sun Mar 24 21:04:08 2024 Return-path: Envelope-to: guile-devel@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 1roU4d-0007LU-P5 for guile-devel@m.gmane-mx.org; Sun, 24 Mar 2024 21:04:07 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1roU4V-0003kQ-Hw; Sun, 24 Mar 2024 16:03:59 -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 1roTj2-0005Vh-4E for guile-devel@gnu.org; Sun, 24 Mar 2024 15:41:48 -0400 Original-Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1roTj0-00017B-G1 for guile-devel@gnu.org; Sun, 24 Mar 2024 15:41:47 -0400 Original-Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-29df0ca87d1so3062577a91.2 for ; Sun, 24 Mar 2024 12:41:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oakland.edu; s=google; t=1711309304; x=1711914104; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=vIe8ktXVQdJ/cRXO0A7Gyg7hJTLejvzrfmzw4HhWBXI=; b=R27CuMN1BxEcF35Jhy6Cx+BP3OGLpA+IldXf8pgXGDQCWMdF4YCcgC3VW6uHqYficY yBX37BSXIVqdQDkAs+aN/zZgNzycicOGI9Yt7hlrS9NmIVNFNjpERLdSoV96pRsbCd3f ZIiKIbrXLz0Gv65zpAZ0FTdLjFDm4fwtU9h9/b6xZjY324QmNSQCsc7u2UwHrop51til FM3DS1YTNVrG2beip/YlWIkh01MGQAajcIN+buCpTWAa6zsDwDL1H8/Kf7a+fKQInGin C94RDkArZ6ATCAlwthcFoXh3fO/nPZXn+qtrL/4c/ngebIPfxH3awLoznsjwq/oe9Y/i CTvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711309304; x=1711914104; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vIe8ktXVQdJ/cRXO0A7Gyg7hJTLejvzrfmzw4HhWBXI=; b=KlnnLudJxh0VyvgZHN/37zO/IpTYSUHkiDd4kObYtugse6qwcSDzfBHwj2JOVxZS0I JBTIsMUP3QvtETux7jA7LoFzJlXBYCT02hVwO9tFJq7bcdlbp0xTYcGcuIN5x/RKHeB5 UqHDI6jJGsmklcZ/8pyJ2YRVZuC777/R/k2kMg1pWWnYScllQbeA82BqxCUp0FT+sbAE e46WiQA/gwCsFryItGyb5TntJn+JA92/uNtnlbXbMLIVghKgqBlFJ2Mob9OzWuKTmUEL rEXKTY+Fv/6+on6e83D3h/IbRwjtdV0ftj4D5xa5bRRUl+Dq7MAaLq+DAXSEY5990vRr 63ew== X-Gm-Message-State: AOJu0YwF8UhugCQtc95g/M779YmXVuSt9cvLQlyVXyY85+KoH2iItgBE QbUoNVPZoIFFMzWZDyjWusXoaBHP/JaUpwrryvhY2JgPKuzpO8x1tkvZSSaChZbNQhhWfsmXGvN X7+US8gY0ZhNO/ptkC4GeCtDaYZXACpvJLs4fnlKt4iiEiaU= X-Google-Smtp-Source: AGHT+IFxvmgba59kqtIien8xL4AL8k0gkjncbrqRGwbxAj/Jk8vGFWNu9/gg5EPjg/7+C1rxKjoJ4Y9QkOnzOrXfV2Y= X-Received: by 2002:a17:90b:109:b0:29c:5ba6:c518 with SMTP id p9-20020a17090b010900b0029c5ba6c518mr4404042pjz.6.1711309304048; Sun, 24 Mar 2024 12:41:44 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=rjraymond@oakland.edu; helo=mail-pj1-x102f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 24 Mar 2024 16:03:58 -0400 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:22367 Archived-At: --0000000000002b8ebe06146d3f42 Content-Type: text/plain; charset="UTF-8" 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 --0000000000002b8ebe06146d3f42 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello, all.
I was able to build a non-block= ing web-server using network sockets. However, the existing guile web/serve= r.scm implementation is single-threaded and therefore blocking, which is su= b-optimal for some use-cases.

I suggest we slightl= y 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, b= ut you get the picture.

(define (listen sock)
=C2=A0 (let* (
= =C2=A0 =C2=A0 (client-connection (accept sock))
=C2=A0 =C2=A0 (client-de= tails (cdr client-connection))
=C2=A0 =C2=A0 (client (car client-connect= ion)))
=C2=A0 =C2=A0 (begin-thread
=C2=A0 =C2=A0 =C2=A0 (sigaction SI= GPIPE SIG_IGN)
=C2=A0 =C2=A0 =C2=A0 (handle client)
=C2=A0 =C2=A0 =C2= =A0 (close client))
=C2=A0 =C2=A0 ))

This shoul= dn'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
--0000000000002b8ebe06146d3f42--