ruby-lsapi 5.8 → 5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25bb6c397ec50194cb0b748361b0e84623148ca88803ebd9d5a25ac2d445d367
4
- data.tar.gz: 5469a7a000fb7cf30cade06b6e3d5d261bd622719ddfaddc5350e94227edcdf2
3
+ metadata.gz: f10920844cbc990bc8c86333ae9c906ac69fcf6de5dea66dd2c5aefc5c54dfbb
4
+ data.tar.gz: 16f8bb6da43c797709294552a7a2c90b159933eecc5481db4af2e69c26a08175
5
5
  SHA512:
6
- metadata.gz: beea3f11b03496201e142ff6047e55372bf1a819e165a702d2bcd1b25848621681963065ba5b70110d78537b1f0cc94b40cad6615657ab1652c49eda4ae261a3
7
- data.tar.gz: afdb209facd04c02ae70a44c0e152073e914adf238955ff243c7d34d753507b56ad18a977d50ad68951016cabbd979fee8065a4b77385542ed8a0e1e12cc012a
6
+ metadata.gz: 66004fe6644e356b6992e877aaa3d5a6964d271066f50ee9603365b100d5ecb467a69dec5c215e80afb7ca239cb3de21d83a34ffacf21f05addabce381a98a2b
7
+ data.tar.gz: f1561515cd625f60689a8a55582e430f88e6686b80502d00c44299b7afaa12591bcaa44fbd4e795e71f8893bbb599e4c93740fadd73c761f2feb4ffff5693a7c
data/README CHANGED
@@ -15,7 +15,8 @@ USAGE
15
15
  General CGI scripts
16
16
  ^^^^^^^^^^^^^^^^^^^
17
17
  The most efficient way to use LSAPI interface is to modify your CGI scripts.
18
- You need to add the following code to your CGI scripts:
18
+ For a single-process application (LSAPI_CHILDREN <= 1), add the following
19
+ code to your CGI scripts:
19
20
 
20
21
  require 'lsapi'
21
22
 
@@ -26,6 +27,15 @@ You need to add the following code to your CGI scripts:
26
27
 
27
28
  end
28
29
 
30
+ For self-managed prefork applications, use one of the bundled runners. They
31
+ load the Ruby application before accepting connections, then use Ruby's fork
32
+ method together with LSAPI.postfork_child and LSAPI.postfork_parent. This
33
+ preserves copy-on-write sharing without bypassing Ruby's fork hooks.
34
+
35
+ Ruby LSAPI refuses to start with an effective UID of 0. The web server must
36
+ select the final application UID before starting Ruby; the runner never starts
37
+ as root and does not perform an in-process UID transition.
38
+
29
39
  There is no need to change the way that how CGI environment variables
30
40
  are being accessed in your scripts.
31
41
 
@@ -162,4 +172,3 @@ Copyright
162
172
 
163
173
  Copyright (C) 2006 Lite Speed Technologies Inc.
164
174
 
165
-
@@ -3,12 +3,27 @@
3
3
  require 'lsapi'
4
4
  require 'cgi'
5
5
 
6
-
7
- while LSAPI.accept != nil
6
+ def handle_request
8
7
  cgi = CGI.new
9
8
  name = cgi['name']
10
9
  puts cgi.header
11
10
  puts "Hello #{name}! <br> " if name
12
11
  puts "You are from #{cgi.remote_addr}<br>"
12
+ end
13
13
 
14
+ if LSAPI.respond_to?("accept_new_connection")
15
+ while LSAPI.accept_new_connection != nil
16
+ begin
17
+ fork do
18
+ LSAPI.postfork_child
19
+ handle_request while LSAPI.accept != nil
20
+ end
21
+ LSAPI.postfork_parent
22
+ rescue SystemCallError => e
23
+ LSAPI.postfork_failed
24
+ warn "ruby-lsapi: fork failed: #{e.message}"
25
+ end
26
+ end
27
+ else
28
+ handle_request while LSAPI.accept != nil
14
29
  end
@@ -4,8 +4,25 @@ require 'lsapi'
4
4
 
5
5
  $count = 0;
6
6
 
7
- while LSAPI.accept != nil
7
+ def handle_request
8
8
  print "HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\nHello World! \##{$count}<br>\r\n"
9
9
  ENV.each_pair {|key, value| print "#{key} is #{value}<br>\r\n" }
10
10
  $count = $count + 1
11
11
  end
12
+
13
+ if LSAPI.respond_to?("accept_new_connection")
14
+ while LSAPI.accept_new_connection != nil
15
+ begin
16
+ fork do
17
+ LSAPI.postfork_child
18
+ handle_request while LSAPI.accept != nil
19
+ end
20
+ LSAPI.postfork_parent
21
+ rescue SystemCallError => e
22
+ LSAPI.postfork_failed
23
+ warn "ruby-lsapi: fork failed: #{e.message}"
24
+ end
25
+ end
26
+ else
27
+ handle_request while LSAPI.accept != nil
28
+ end