unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] Add backlog option to http-open
@ 2013-04-04  4:39 Nala Ginrut
  2013-04-05  0:22 ` Daniel Hartwig
  2013-04-05  0:29 ` Daniel Hartwig
  0 siblings, 2 replies; 6+ messages in thread
From: Nala Ginrut @ 2013-04-04  4:39 UTC (permalink / raw)
  To: guile-devel@gnu.org

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

Here's a patch to add backlog option to http-open, users may use it
like:

-----------------------cut------------------------
(run-server (lambda (r b) ...) 
            'http
            '(#:port 1234 #:backlog 1024))
-----------------------end------------------------

I don't think it's necessary to add the docs since it's explicit.
It may help for some guys like me. ;-)

Happy hacking!


[-- Attachment #2: 0001-Add-backlog-option-to-http-open.patch --]
[-- Type: text/x-patch, Size: 1026 bytes --]

From b75008bd60967be9935ef6e7bb146832cf852ab3 Mon Sep 17 00:00:00 2001
From: Nala Ginrut <nalaginrut@gmail.com>
Date: Thu, 4 Apr 2013 12:33:09 +0800
Subject: [PATCH] Add backlog option to http-open

* web/server/http.scm: Add #:backlog to http-open, users may specify
                       backlog to the inner http server.
---
 module/web/server/http.scm |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/module/web/server/http.scm b/module/web/server/http.scm
index cda44f4..c814286 100644
--- a/module/web/server/http.scm
+++ b/module/web/server/http.scm
@@ -62,8 +62,9 @@
                               (inet-pton family host)
                               INADDR_LOOPBACK))
                     (port 8080)
+                    (backlog 128)
                     (socket (make-default-socket family addr port)))
-  (listen socket 128)
+  (listen socket backlog)
   (sigaction SIGPIPE SIG_IGN)
   (let ((poll-set (make-empty-poll-set)))
     (poll-set-add! poll-set socket *events*)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add backlog option to http-open
  2013-04-04  4:39 [PATCH] Add backlog option to http-open Nala Ginrut
@ 2013-04-05  0:22 ` Daniel Hartwig
  2013-04-06  4:14   ` Nala Ginrut
  2013-04-05  0:29 ` Daniel Hartwig
  1 sibling, 1 reply; 6+ messages in thread
From: Daniel Hartwig @ 2013-04-05  0:22 UTC (permalink / raw)
  To: guile-devel@gnu.org

On 4 April 2013 12:39, Nala Ginrut <nalaginrut@gmail.com> wrote:
> I don't think it's necessary to add the docs since it's explicit.
> It may help for some guys like me. ;-)

Every part of the API must be documented.  How else do guys like you
know this is there?



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add backlog option to http-open
  2013-04-04  4:39 [PATCH] Add backlog option to http-open Nala Ginrut
  2013-04-05  0:22 ` Daniel Hartwig
@ 2013-04-05  0:29 ` Daniel Hartwig
  2013-04-05  1:29   ` Nala Ginrut
  1 sibling, 1 reply; 6+ messages in thread
From: Daniel Hartwig @ 2013-04-05  0:29 UTC (permalink / raw)
  To: Nala Ginrut; +Cc: guile-devel@gnu.org

On 4 April 2013 12:39, Nala Ginrut <nalaginrut@gmail.com> wrote:
> Here's a patch to add backlog option to http-open, users may use it
> like:
>
> -----------------------cut------------------------
> (run-server (lambda (r b) ...)
>             'http
>             '(#:port 1234 #:backlog 1024))
> -----------------------end------------------------
>

You want to be quite sure about using a much larger value here.  Of
course, the kernel will ignore settings above its own configuration,
but if your server reaches a backlog of 128 this already indicates a
delay in servicing those requests.  Increasing the backlog to 1024 is
going to substantially increase that delay, no?



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add backlog option to http-open
  2013-04-05  0:29 ` Daniel Hartwig
@ 2013-04-05  1:29   ` Nala Ginrut
  0 siblings, 0 replies; 6+ messages in thread
From: Nala Ginrut @ 2013-04-05  1:29 UTC (permalink / raw)
  To: Daniel Hartwig; +Cc: guile-devel

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

在 2013-4-5 AM8:29,"Daniel Hartwig" <mandyke@gmail.com>写道:
>
> On 4 April 2013 12:39, Nala Ginrut <nalaginrut@gmail.com> wrote:
> > Here's a patch to add backlog option to http-open, users may use it
> > like:
> >
> > -----------------------cut------------------------
> > (run-server (lambda (r b) ...)
> >             'http
> >             '(#:port 1234 #:backlog 1024))
> > -----------------------end------------------------
> >
>
> You want to be quite sure about using a much larger value here.  Of
> course, the kernel will ignore settings above its own configuration,
> but if your server reaches a backlog of 128 this already indicates a
> delay in servicing those requests.  Increasing the backlog to 1024 is
> going to substantially increase that delay, no?

That's users' consideration, we just provide mechanism.
And in practical, users will configure the kernel or modify it.

For high concurrency server, that delay is endurable, the aim is to hold
more connections.
Anyway, that's users policy. The upstream has to provide mechanism.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add backlog option to http-open
  2013-04-05  0:22 ` Daniel Hartwig
@ 2013-04-06  4:14   ` Nala Ginrut
  2013-04-07  6:56     ` Daniel Hartwig
  0 siblings, 1 reply; 6+ messages in thread
From: Nala Ginrut @ 2013-04-06  4:14 UTC (permalink / raw)
  To: Daniel Hartwig; +Cc: guile-devel@gnu.org

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

On Fri, 2013-04-05 at 08:22 +0800, Daniel Hartwig wrote:
> On 4 April 2013 12:39, Nala Ginrut <nalaginrut@gmail.com> wrote:
> > I don't think it's necessary to add the docs since it's explicit.
> > It may help for some guys like me. ;-)
> 
> Every part of the API must be documented.  How else do guys like you
> know this is there?
> 

Resend patch, added the example for #:backlog.
Since there's no docs for all run-server open-params, but examples.
So I just added the example. I think it's enough to explain the usage.

Please ping me if it's necessary to add more docs for open-params in
detail. But it's another brand new patch I think.

Thanks! 

[-- Attachment #2: 0001-Add-backlog-option-to-http-open.patch --]
[-- Type: text/x-patch, Size: 1559 bytes --]

From a5cae0d525bbbdcc65f65edb22908a8034e6fb8e Mon Sep 17 00:00:00 2001
From: Nala Ginrut <nalaginrut@gmail.com>
Date: Thu, 4 Apr 2013 12:33:09 +0800
Subject: [PATCH] Add backlog option to http-open

* web/server/http.scm: Add #:backlog to http-open, users may specify
                       backlog to the inner http server.

* doc/ref/web.texi: Add example for #:backlog.
---
 doc/ref/web.texi           |    2 ++
 module/web/server/http.scm |    3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/doc/ref/web.texi b/doc/ref/web.texi
index 0d41f9f..288699e 100644
--- a/doc/ref/web.texi
+++ b/doc/ref/web.texi
@@ -1667,6 +1667,8 @@ implementation's open function.
 (run-server handler 'http '(#:family AF_INET6 #:port 8081))
 ;; Custom socket
 (run-server handler 'http `(#:socket ,(sudo-make-me-a-socket)))
+;; Custom backlog (the default backlog is 128)
+(run-server handler 'http `(#:backlog 1000)) 
 @end example
 @end deffn
 
diff --git a/module/web/server/http.scm b/module/web/server/http.scm
index cda44f4..c814286 100644
--- a/module/web/server/http.scm
+++ b/module/web/server/http.scm
@@ -62,8 +62,9 @@
                               (inet-pton family host)
                               INADDR_LOOPBACK))
                     (port 8080)
+                    (backlog 128)
                     (socket (make-default-socket family addr port)))
-  (listen socket 128)
+  (listen socket backlog)
   (sigaction SIGPIPE SIG_IGN)
   (let ((poll-set (make-empty-poll-set)))
     (poll-set-add! poll-set socket *events*)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add backlog option to http-open
  2013-04-06  4:14   ` Nala Ginrut
@ 2013-04-07  6:56     ` Daniel Hartwig
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Hartwig @ 2013-04-07  6:56 UTC (permalink / raw)
  To: Nala Ginrut; +Cc: guile-devel@gnu.org

On 6 April 2013 12:14, Nala Ginrut <nalaginrut@gmail.com> wrote:
> Resend patch, added the example for #:backlog.
> Since there's no docs for all run-server open-params, but examples.
> So I just added the example. I think it's enough to explain the usage.

You missed to add it to the preceding ‘@deffn’.

I don't think an example is appropriate for such a specialized parameter.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-04-07  6:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-04  4:39 [PATCH] Add backlog option to http-open Nala Ginrut
2013-04-05  0:22 ` Daniel Hartwig
2013-04-06  4:14   ` Nala Ginrut
2013-04-07  6:56     ` Daniel Hartwig
2013-04-05  0:29 ` Daniel Hartwig
2013-04-05  1:29   ` Nala Ginrut

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).