fcgi 0.8.5 → 0.8.6
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.
- data/ChangeLog +26 -0
- data/Makefile +131 -0
- data/README +3 -4
- data/README.signals +76 -0
- data/Rakefile +171 -0
- data/ext/fcgi/extconf.rb +9 -0
- data/{fcgi.c → ext/fcgi/fcgi.c} +23 -3
- metadata +12 -11
- data/MANIFEST +0 -5
- data/extconf.rb +0 -9
- data/fcgi.gemspec +0 -16
data/ChangeLog
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Fri Apr 1 10:20:14 JST 2005 sugi@nemui.org
|
2
|
+
* Include errno.h
|
3
|
+
|
4
|
+
Fri Apr 1 08:09:13 JST 2005 aredridel@nbtsc.org
|
5
|
+
* Report actual errors
|
6
|
+
|
7
|
+
Adds reporting of errors fcgi experiences. Credit to David Heinemier Hansson
|
8
|
+
for discovery.
|
9
|
+
|
10
|
+
Fri Apr 1 08:08:07 JST 2005 aredridel@nbtsc.org
|
11
|
+
* FHS Include Paths
|
12
|
+
|
13
|
+
Wed Mar 30 21:45:11 JST 2005 sugi@nemui.org
|
14
|
+
* 16k+request-memleak
|
15
|
+
fix memory leak when 16k+/reqest.
|
16
|
+
from http://enigo.com/projects/iowa/fcgipatch.html
|
17
|
+
|
18
|
+
Wed Mar 30 21:43:02 JST 2005 sugi@nemui.org
|
19
|
+
* fix-check_stream_error
|
20
|
+
Simple fix in CHECK_STREAM_ERROR for Potential DoS
|
21
|
+
see http://groups-beta.google.com/group/comp.lang.ruby/browse_thread/thread/f51e79974a454b70/54fe207411e9eb05
|
22
|
+
for details.
|
23
|
+
|
24
|
+
Wed Mar 30 21:40:22 JST 2005 sugi@nemui.org
|
25
|
+
* init-from-0.8.5
|
26
|
+
Initalize DARCS repository from MoonWolf's 0.8.5 release.
|
data/Makefile
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
|
2
|
+
SHELL = /bin/sh
|
3
|
+
|
4
|
+
#### Start of system configuration section. ####
|
5
|
+
|
6
|
+
srcdir = ext/fcgi
|
7
|
+
topdir = /opt/local/lib/ruby/1.8/powerpc-darwin8.1.0
|
8
|
+
hdrdir = $(topdir)
|
9
|
+
VPATH = $(srcdir)
|
10
|
+
prefix = $(DESTDIR)/opt/local
|
11
|
+
exec_prefix = $(prefix)
|
12
|
+
sitedir = $(prefix)/lib/ruby/site_ruby
|
13
|
+
rubylibdir = $(libdir)/ruby/$(ruby_version)
|
14
|
+
builddir = $(ac_builddir)
|
15
|
+
archdir = $(rubylibdir)/$(arch)
|
16
|
+
sbindir = $(exec_prefix)/sbin
|
17
|
+
vendordir = $(prefix)/lib/ruby/vendor_ruby
|
18
|
+
compile_dir = $(DESTDIR)/opt/local/var/db/dports/build/file._opt_local_var_db_dports_sources_rsync.rsync.opendarwin.org_dpupdate_dports_lang_ruby/work/ruby-1.8.2
|
19
|
+
datadir = $(prefix)/share
|
20
|
+
includedir = $(prefix)/include
|
21
|
+
infodir = $(prefix)/info
|
22
|
+
top_builddir = $(ac_top_builddir)
|
23
|
+
sysconfdir = $(prefix)/etc
|
24
|
+
mandir = $(DESTDIR)/opt/local/share/man
|
25
|
+
libdir = $(exec_prefix)/lib
|
26
|
+
sharedstatedir = $(prefix)/com
|
27
|
+
oldincludedir = $(DESTDIR)/usr/include
|
28
|
+
sitearchdir = $(sitelibdir)/$(sitearch)
|
29
|
+
vendorarchdir = $(vendorlibdir)/$(vendorarch)
|
30
|
+
bindir = $(exec_prefix)/bin
|
31
|
+
localstatedir = $(prefix)/var
|
32
|
+
vendorlibdir = $(vendordir)/$(ruby_version)
|
33
|
+
sitelibdir = $(sitedir)/$(ruby_version)
|
34
|
+
libexecdir = $(exec_prefix)/libexec
|
35
|
+
|
36
|
+
CC = gcc
|
37
|
+
LIBRUBY = $(LIBRUBY_SO)
|
38
|
+
LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
|
39
|
+
LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
|
40
|
+
LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
|
41
|
+
|
42
|
+
CFLAGS = -fno-common -O -pipe -I/opt/local/include -fno-common -pipe -fno-common
|
43
|
+
CPPFLAGS = -I. -I$(topdir) -I$(hdrdir) -I$(srcdir) -DHAVE_FCGIAPP_H -O -pipe -I/opt/local/include
|
44
|
+
CXXFLAGS = $(CFLAGS)
|
45
|
+
DLDFLAGS = -L/opt/local/lib
|
46
|
+
LDSHARED = cc -dynamic -bundle -undefined suppress -flat_namespace
|
47
|
+
AR = ar
|
48
|
+
EXEEXT =
|
49
|
+
|
50
|
+
RUBY_INSTALL_NAME = ruby
|
51
|
+
RUBY_SO_NAME = $(RUBY_INSTALL_NAME)
|
52
|
+
arch = powerpc-darwin8.1.0
|
53
|
+
sitearch = powerpc-darwin8.1.0
|
54
|
+
vendorarch = powerpc-darwin8.1.0
|
55
|
+
ruby_version = 1.8
|
56
|
+
ruby = /opt/local/bin/ruby
|
57
|
+
RUBY = $(ruby)
|
58
|
+
RM = $(RUBY) -run -e rm -- -f
|
59
|
+
MAKEDIRS = $(RUBY) -run -e mkdir -- -p
|
60
|
+
INSTALL_PROG = $(RUBY) -run -e install -- -vpm 0755
|
61
|
+
INSTALL_DATA = $(RUBY) -run -e install -- -vpm 0644
|
62
|
+
|
63
|
+
#### End of system configuration section. ####
|
64
|
+
|
65
|
+
|
66
|
+
LIBPATH = -L"$(libdir)"
|
67
|
+
DEFFILE =
|
68
|
+
|
69
|
+
CLEANFILES =
|
70
|
+
DISTCLEANFILES =
|
71
|
+
|
72
|
+
target_prefix =
|
73
|
+
LOCAL_LIBS =
|
74
|
+
LIBS = $(LIBRUBYARG_SHARED) -lfcgi -ldl -lobjc
|
75
|
+
OBJS = fcgi.o
|
76
|
+
TARGET = fcgi
|
77
|
+
DLLIB = $(TARGET).bundle
|
78
|
+
STATIC_LIB = $(TARGET).a
|
79
|
+
|
80
|
+
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
81
|
+
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
82
|
+
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
83
|
+
|
84
|
+
CLEANLIBS = "$(TARGET).{lib,exp,il?,tds,map}" $(DLLIB)
|
85
|
+
CLEANOBJS = "*.{o,a,s[ol],pdb,bak}"
|
86
|
+
|
87
|
+
all: $(DLLIB)
|
88
|
+
static: $(STATIC_LIB)
|
89
|
+
|
90
|
+
clean:
|
91
|
+
@$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
|
92
|
+
|
93
|
+
distclean: clean
|
94
|
+
@$(RM) Makefile extconf.h conftest.* mkmf.log
|
95
|
+
@$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
|
96
|
+
|
97
|
+
realclean: distclean
|
98
|
+
install: $(RUBYARCHDIR)
|
99
|
+
install: $(RUBYARCHDIR)/$(DLLIB)
|
100
|
+
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB) $(RUBYARCHDIR)
|
101
|
+
@$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
|
102
|
+
$(RUBYARCHDIR):
|
103
|
+
@$(MAKEDIRS) $(RUBYARCHDIR)
|
104
|
+
|
105
|
+
site-install: install
|
106
|
+
|
107
|
+
.SUFFIXES: .c .cc .m .cxx .cpp .C .o
|
108
|
+
|
109
|
+
.cc.o:
|
110
|
+
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
|
111
|
+
|
112
|
+
.cpp.o:
|
113
|
+
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
|
114
|
+
|
115
|
+
.cxx.o:
|
116
|
+
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
|
117
|
+
|
118
|
+
.C.o:
|
119
|
+
$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $<
|
120
|
+
|
121
|
+
.c.o:
|
122
|
+
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
|
123
|
+
|
124
|
+
$(DLLIB): $(OBJS)
|
125
|
+
@-$(RM) $@
|
126
|
+
$(LDSHARED) $(DLDFLAGS) $(LIBPATH) -o $(DLLIB) $(OBJS) $(LOCAL_LIBS) $(LIBS)
|
127
|
+
|
128
|
+
$(STATIC_LIB): $(OBJS)
|
129
|
+
$(AR) cru $@ $(OBJS)
|
130
|
+
@-ranlib $(DLLIB) 2> /dev/null || true
|
131
|
+
|
data/README
CHANGED
@@ -5,7 +5,7 @@ Version 0.8.5
|
|
5
5
|
== Depends
|
6
6
|
|
7
7
|
=== C version
|
8
|
-
* http://www.fastcgi.com/#TheDevKit
|
8
|
+
* ((<libfcgi|URL:http://www.fastcgi.com/#TheDevKit>))(FastCGI Developer's Kit)
|
9
9
|
|
10
10
|
=== Pure Ruby Version
|
11
11
|
* StringIO
|
@@ -97,8 +97,8 @@ standard CGI library.
|
|
97
97
|
|
98
98
|
== License
|
99
99
|
|
100
|
-
* http://www.ruby-lang.org/ja/LICENSE.txt (Japanese)
|
101
|
-
* http://www.ruby-lang.org/en/LICENSE.txt (English)
|
100
|
+
* ((<URL:http://www.ruby-lang.org/ja/LICENSE.txt>)) (Japanese)
|
101
|
+
* ((<URL:http://www.ruby-lang.org/en/LICENSE.txt>)) (English)
|
102
102
|
|
103
103
|
== Copyright
|
104
104
|
|
@@ -108,4 +108,3 @@ standard CGI library.
|
|
108
108
|
fastcgi.rb 0.7 Copyright (C) 2001 Eli Green
|
109
109
|
fcgi.rb 0.8 Copyright (C) 2002 MoonWolf <moonwolf@moonwolf.com>
|
110
110
|
fcgi.rb 0.8.5 Copyright (C) 2004 Minero Aoki
|
111
|
-
|
data/README.signals
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
= Handling of SIGUSR1
|
2
|
+
|
3
|
+
When you request a 'graceful' restart of Apache, mod_fastcgi sends a SIGUSR1
|
4
|
+
to each of the fastcgi worker processes. The intention is that each one
|
5
|
+
should finish the current request, and then exit, at which point Apache will
|
6
|
+
restart it. Of course, if the worker isn't doing anything, it should die
|
7
|
+
immediately.
|
8
|
+
|
9
|
+
This is implemented in the fcgi C library as follows:
|
10
|
+
|
11
|
+
- a signal handler is installed for SIGUSR1, which just sets a flag
|
12
|
+
(shutdownPending) and returns
|
13
|
+
- fcgi sits inside an accept() call waiting for a new request
|
14
|
+
- if this accept() call terminates with EINTR, and this flag is set, then
|
15
|
+
it returns with no request
|
16
|
+
|
17
|
+
Unfortunately, Ruby defeats this mechanism in at least two ways:
|
18
|
+
|
19
|
+
1. Ruby installs its own signal handlers for a host of common signals,
|
20
|
+
including USR1. The fcgi library will not install its own handler if it
|
21
|
+
detects that a handler has already been set (i.e. the current handler is not
|
22
|
+
SIG_DFL)
|
23
|
+
|
24
|
+
2. When Ruby installs its own signal handlers, it does so with SA_RESTART
|
25
|
+
set. This means that the accept() call does not terminate with EINTR; it is
|
26
|
+
restarted automatically by the OS.
|
27
|
+
|
28
|
+
When a signal comes in during the accept(), Ruby's own handler does nothing
|
29
|
+
except store it in a queue to be processed later. It is only when the
|
30
|
+
accept() call completes, i.e. when a genuine new request comes in, that Ruby
|
31
|
+
takes action. Unfortunately it's too late by then, and if that
|
32
|
+
already-accepted request is not honoured, a 500 Internal Error will be
|
33
|
+
returned to the client.
|
34
|
+
|
35
|
+
The simplest solution to this would be to remove Ruby's SIGUSR1 handler
|
36
|
+
before initialising the FastCGI library.
|
37
|
+
|
38
|
+
However, a cleaner solution is to call rb_thread_select before going into
|
39
|
+
FastCGI's accept loop. If a signal happens during the select, it can be
|
40
|
+
handled using Ruby's normal mechanisms. This also gives a very useful
|
41
|
+
side-benefit, which is that FCGI::accept no longer blocks out other Ruby
|
42
|
+
threads. The program below demonstrates this problem; its background logging
|
43
|
+
thread is supposed to write a message every 10 seconds, but under older
|
44
|
+
versions of ruby-fcgi it does not do so if it is waiting for a new request.
|
45
|
+
|
46
|
+
#!/usr/local/bin/ruby
|
47
|
+
require "fcgi"
|
48
|
+
|
49
|
+
Thread.new do
|
50
|
+
f = File.new("/tmp/fcgi.log","a")
|
51
|
+
f.sync=true
|
52
|
+
while true
|
53
|
+
f.puts "#{Time.now.to_s} pid #{$$}"
|
54
|
+
sleep 10
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
FCGI.each_cgi {|cgi|
|
59
|
+
name = cgi['name'][0]
|
60
|
+
puts cgi.header
|
61
|
+
puts "Hey! You are #{name} " if name
|
62
|
+
puts "Connecting from #{cgi.remote_addr}"
|
63
|
+
}
|
64
|
+
|
65
|
+
Having protected the accept() with a ruby select(), you can then handle
|
66
|
+
signals as follows:
|
67
|
+
|
68
|
+
- call FCGI::accept (it will raise an exception if USR1 is called)
|
69
|
+
- install a USR1 handler
|
70
|
+
- process the request
|
71
|
+
- remove the USR1 handler
|
72
|
+
|
73
|
+
The USR1 handler should set a flag to note if a USR1 signal came in while
|
74
|
+
the request was being processed; you terminate the loop if it was set. The
|
75
|
+
overall effect is that USR1 will cause the process to terminate, but without
|
76
|
+
causing a half-completed request.
|
data/Rakefile
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
require 'rake/contrib/rubyforgepublisher'
|
7
|
+
|
8
|
+
PKG_VERSION = "0.8.6"
|
9
|
+
PKG_NAME = "fcgi"
|
10
|
+
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
11
|
+
|
12
|
+
PKG_FILES = FileList[
|
13
|
+
"lib/**/*",
|
14
|
+
"ext/*",
|
15
|
+
"ext/fcgi/fcgi.c*",
|
16
|
+
"[A-Z]*",
|
17
|
+
].exclude(/\bCVS\b|~$/)
|
18
|
+
|
19
|
+
|
20
|
+
# Publish beta gem
|
21
|
+
desc "Publish the gem on leetsoft"
|
22
|
+
task :publish => [:package] do
|
23
|
+
Rake::SshFilePublisher.new("leetsoft.com", "dist/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
|
24
|
+
Rake::SshFilePublisher.new("leetsoft.com", "dist/pkg", "pkg", "#{PKG_FILE_NAME}.zip").upload
|
25
|
+
Rake::SshFilePublisher.new("leetsoft.com", "dist/pkg", "pkg", "#{PKG_FILE_NAME}.tgz").upload
|
26
|
+
`ssh tobi@leetsoft.com './gemupdate'`
|
27
|
+
end
|
28
|
+
|
29
|
+
spec = Gem::Specification.new do |s|
|
30
|
+
s.name = PKG_NAME
|
31
|
+
s.version = PKG_VERSION
|
32
|
+
s.summary = %q{FastCGI ruby binding.}
|
33
|
+
s.require_paths = ["."]
|
34
|
+
s.email = %q{moonwolf@moonwolf.com}
|
35
|
+
s.homepage = %q{http://rwiki.moonwolf.com/rw-cgi.cgi?cmd=view;name=fcgi}
|
36
|
+
s.autorequire = %q{fcgi}
|
37
|
+
s.has_rdoc = true
|
38
|
+
s.files = PKG_FILES
|
39
|
+
s.extra_rdoc_files = ["README"]
|
40
|
+
s.extensions = ["ext/fcgi/extconf.rb"]
|
41
|
+
end
|
42
|
+
|
43
|
+
Rake::GemPackageTask.new(spec) do |p|
|
44
|
+
p.gem_spec = spec
|
45
|
+
p.need_tar = true
|
46
|
+
p.need_zip = true
|
47
|
+
end
|
48
|
+
|
49
|
+
# --- Ruby forge release manager by florian gross -------------------------------------------------
|
50
|
+
|
51
|
+
RUBY_FORGE_PROJECT = 'fcgi'
|
52
|
+
RUBY_FORGE_USER = 'xal'
|
53
|
+
RELEASE_NAME = "REL #{PKG_VERSION}"
|
54
|
+
|
55
|
+
desc "Publish the release files to RubyForge."
|
56
|
+
task :release => [:gem] do
|
57
|
+
files = ["gem"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" }
|
58
|
+
|
59
|
+
if RUBY_FORGE_PROJECT then
|
60
|
+
require 'net/http'
|
61
|
+
require 'open-uri'
|
62
|
+
|
63
|
+
project_uri = "http://rubyforge.org/projects/#{RUBY_FORGE_PROJECT}/"
|
64
|
+
project_data = open(project_uri) { |data| data.read }
|
65
|
+
group_id = project_data[/[?&]group_id=(\d+)/, 1]
|
66
|
+
raise "Couldn't get group id" unless group_id
|
67
|
+
|
68
|
+
# This echos password to shell which is a bit sucky
|
69
|
+
if ENV["RUBY_FORGE_PASSWORD"]
|
70
|
+
password = ENV["RUBY_FORGE_PASSWORD"]
|
71
|
+
else
|
72
|
+
print "#{RUBY_FORGE_USER}@rubyforge.org's password: "
|
73
|
+
password = STDIN.gets.chomp
|
74
|
+
end
|
75
|
+
|
76
|
+
login_response = Net::HTTP.start("rubyforge.org", 80) do |http|
|
77
|
+
data = [
|
78
|
+
"login=1",
|
79
|
+
"form_loginname=#{RUBY_FORGE_USER}",
|
80
|
+
"form_pw=#{password}"
|
81
|
+
].join("&")
|
82
|
+
http.post("/account/login.php", data)
|
83
|
+
end
|
84
|
+
|
85
|
+
cookie = login_response["set-cookie"]
|
86
|
+
raise "Login failed" unless cookie
|
87
|
+
headers = { "Cookie" => cookie }
|
88
|
+
|
89
|
+
release_uri = "http://rubyforge.org/frs/admin/?group_id=#{group_id}"
|
90
|
+
release_data = open(release_uri, headers) { |data| data.read }
|
91
|
+
package_id = release_data[/[?&]package_id=(\d+)/, 1]
|
92
|
+
raise "Couldn't get package id" unless package_id
|
93
|
+
|
94
|
+
first_file = true
|
95
|
+
release_id = ""
|
96
|
+
|
97
|
+
files.each do |filename|
|
98
|
+
basename = File.basename(filename)
|
99
|
+
file_ext = File.extname(filename)
|
100
|
+
file_data = File.open(filename, "rb") { |file| file.read }
|
101
|
+
|
102
|
+
puts "Releasing #{basename}..."
|
103
|
+
|
104
|
+
release_response = Net::HTTP.start("rubyforge.org", 80) do |http|
|
105
|
+
release_date = Time.now.strftime("%Y-%m-%d %H:%M")
|
106
|
+
type_map = {
|
107
|
+
".zip" => "3000",
|
108
|
+
".tgz" => "3110",
|
109
|
+
".gz" => "3110",
|
110
|
+
".gem" => "1400"
|
111
|
+
}; type_map.default = "9999"
|
112
|
+
type = type_map[file_ext]
|
113
|
+
boundary = "rubyqMY6QN9bp6e4kS21H4y0zxcvoor"
|
114
|
+
|
115
|
+
query_hash = if first_file then
|
116
|
+
{
|
117
|
+
"group_id" => group_id,
|
118
|
+
"package_id" => package_id,
|
119
|
+
"release_name" => RELEASE_NAME,
|
120
|
+
"release_date" => release_date,
|
121
|
+
"type_id" => type,
|
122
|
+
"processor_id" => "8000", # Any
|
123
|
+
"release_notes" => "",
|
124
|
+
"release_changes" => "",
|
125
|
+
"preformatted" => "1",
|
126
|
+
"submit" => "1"
|
127
|
+
}
|
128
|
+
else
|
129
|
+
{
|
130
|
+
"group_id" => group_id,
|
131
|
+
"release_id" => release_id,
|
132
|
+
"package_id" => package_id,
|
133
|
+
"step2" => "1",
|
134
|
+
"type_id" => type,
|
135
|
+
"processor_id" => "8000", # Any
|
136
|
+
"submit" => "Add This File"
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
query = "?" + query_hash.map do |(name, value)|
|
141
|
+
[name, URI.encode(value)].join("=")
|
142
|
+
end.join("&")
|
143
|
+
|
144
|
+
data = [
|
145
|
+
"--" + boundary,
|
146
|
+
"Content-Disposition: form-data; name=\"userfile\"; filename=\"#{basename}\"",
|
147
|
+
"Content-Type: application/octet-stream",
|
148
|
+
"Content-Transfer-Encoding: binary",
|
149
|
+
"", file_data, ""
|
150
|
+
].join("\x0D\x0A")
|
151
|
+
|
152
|
+
release_headers = headers.merge(
|
153
|
+
"Content-Type" => "multipart/form-data; boundary=#{boundary}"
|
154
|
+
)
|
155
|
+
|
156
|
+
target = first_file ? "/frs/admin/qrs.php" : "/frs/admin/editrelease.php"
|
157
|
+
http.post(target + query, data, release_headers)
|
158
|
+
end
|
159
|
+
|
160
|
+
if first_file then
|
161
|
+
release_id = release_response.body[/release_id=(\d+)/, 1]
|
162
|
+
raise("Couldn't get release id") unless release_id
|
163
|
+
end
|
164
|
+
|
165
|
+
first_file = false
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
|
data/ext/fcgi/extconf.rb
ADDED
data/{fcgi.c → ext/fcgi/fcgi.c}
RENAMED
@@ -7,9 +7,14 @@
|
|
7
7
|
#include <stdio.h>
|
8
8
|
#include <sys/types.h>
|
9
9
|
#include <unistd.h>
|
10
|
+
#include <errno.h>
|
10
11
|
|
11
12
|
#include "ruby.h"
|
13
|
+
#ifdef HAVE_FASTCGI_FCGIAPP_H
|
14
|
+
#include <fastcgi/fcgiapp.h>
|
15
|
+
#else
|
12
16
|
#include "fcgiapp.h"
|
17
|
+
#endif
|
13
18
|
|
14
19
|
static VALUE cFCGI;
|
15
20
|
static VALUE eFCGIError;
|
@@ -37,6 +42,12 @@ static void fcgi_mark(fcgi_data *data)
|
|
37
42
|
rb_gc_mark(data->env);
|
38
43
|
}
|
39
44
|
|
45
|
+
static void fcgi_free_req(fcgi_data *data)
|
46
|
+
{
|
47
|
+
free(data->req);
|
48
|
+
free(data);
|
49
|
+
}
|
50
|
+
|
40
51
|
static VALUE fcgi_s_accept(VALUE self)
|
41
52
|
{
|
42
53
|
int status;
|
@@ -64,7 +75,7 @@ static VALUE fcgi_s_accept(VALUE self)
|
|
64
75
|
VALUE obj,key, value;
|
65
76
|
char *pkey,*pvalue;
|
66
77
|
|
67
|
-
obj = Data_Make_Struct(self, fcgi_data, fcgi_mark,
|
78
|
+
obj = Data_Make_Struct(self, fcgi_data, fcgi_mark, fcgi_free_req, data);
|
68
79
|
data->req = req;
|
69
80
|
data->in = Data_Wrap_Struct(cFCGIStream, 0, 0, req->in);
|
70
81
|
data->out = Data_Wrap_Struct(cFCGIStream, 0, 0, req->out);
|
@@ -153,9 +164,11 @@ static VALUE fcgi_finish(VALUE self)
|
|
153
164
|
|
154
165
|
#define CHECK_STREAM_ERROR(stream) {\
|
155
166
|
int err = FCGX_GetError(stream);\
|
167
|
+
extern int errno; \
|
156
168
|
if (err) {\
|
157
169
|
if (err > 0) {\
|
158
|
-
|
170
|
+
errno = err;\
|
171
|
+
rb_sys_fail(NULL);\
|
159
172
|
}\
|
160
173
|
else {\
|
161
174
|
switch (err) {\
|
@@ -379,7 +392,10 @@ static VALUE fcgi_stream_read(int argc, VALUE *argv, VALUE self)
|
|
379
392
|
buff = ALLOC_N(char, 16384);
|
380
393
|
n = FCGX_GetStr(buff, 16384, stream);
|
381
394
|
CHECK_STREAM_ERROR(stream);
|
382
|
-
if (n == 0)
|
395
|
+
if (n == 0) {
|
396
|
+
free(buff);
|
397
|
+
return Qnil;
|
398
|
+
}
|
383
399
|
str = rb_str_new(buff, n);
|
384
400
|
OBJ_TAINT(str);
|
385
401
|
|
@@ -389,9 +405,11 @@ static VALUE fcgi_stream_read(int argc, VALUE *argv, VALUE self)
|
|
389
405
|
if (n > 0) {
|
390
406
|
rb_str_cat(str, buff, n);
|
391
407
|
} else {
|
408
|
+
free(buff);
|
392
409
|
return Qnil;
|
393
410
|
}
|
394
411
|
}
|
412
|
+
free(buff);
|
395
413
|
return str;
|
396
414
|
}
|
397
415
|
|
@@ -404,9 +422,11 @@ static VALUE fcgi_stream_read(int argc, VALUE *argv, VALUE self)
|
|
404
422
|
if (n > 0) {
|
405
423
|
str = rb_str_new(buff, n);
|
406
424
|
OBJ_TAINT(str);
|
425
|
+
free(buff);
|
407
426
|
return str;
|
408
427
|
}
|
409
428
|
else {
|
429
|
+
free(buff);
|
410
430
|
return Qnil;
|
411
431
|
}
|
412
432
|
}
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version:
|
2
|
+
rubygems_version: 0.8.10
|
3
3
|
specification_version: 1
|
4
4
|
name: fcgi
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.8.
|
7
|
-
date:
|
6
|
+
version: 0.8.6
|
7
|
+
date: 2005-06-12
|
8
8
|
summary: FastCGI ruby binding.
|
9
9
|
require_paths:
|
10
10
|
- "."
|
11
|
-
author: "Network Applied Communication Laboratory, Inc., MoonWolf, Eli Green, Minero Aoki"
|
12
11
|
email: moonwolf@moonwolf.com
|
13
12
|
homepage: http://rwiki.moonwolf.com/rw-cgi.cgi?cmd=view;name=fcgi
|
14
13
|
rubyforge_project:
|
@@ -25,20 +24,22 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
24
|
version: 0.0.0
|
26
25
|
version:
|
27
26
|
platform: ruby
|
27
|
+
authors: []
|
28
28
|
files:
|
29
|
-
- lib
|
30
|
-
- extconf.rb
|
31
|
-
- fcgi.c
|
32
|
-
- MANIFEST
|
33
|
-
- README
|
34
|
-
- fcgi.gemspec
|
35
29
|
- lib/fcgi.rb
|
30
|
+
- ext/fcgi
|
31
|
+
- ext/fcgi/fcgi.c
|
32
|
+
- ChangeLog
|
33
|
+
- Makefile
|
34
|
+
- Rakefile
|
35
|
+
- README
|
36
|
+
- README.signals
|
36
37
|
test_files: []
|
37
38
|
rdoc_options: []
|
38
39
|
extra_rdoc_files:
|
39
40
|
- README
|
40
41
|
executables: []
|
41
42
|
extensions:
|
42
|
-
- extconf.rb
|
43
|
+
- ext/fcgi/extconf.rb
|
43
44
|
requirements: []
|
44
45
|
dependencies: []
|
data/MANIFEST
DELETED
data/extconf.rb
DELETED
data/fcgi.gemspec
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
Gem::Specification.new do |s|
|
2
|
-
s.name = %q{fcgi}
|
3
|
-
s.version = "0.8.5"
|
4
|
-
s.date = Time.now
|
5
|
-
s.require_path = %q{.}
|
6
|
-
s.summary = %q{FastCGI ruby binding.}
|
7
|
-
s.author = %q{Network Applied Communication Laboratory, Inc., MoonWolf, Eli Green, Minero Aoki}
|
8
|
-
s.platform = Gem::Platform::RUBY
|
9
|
-
s.files = Dir.glob('**/*')
|
10
|
-
s.email = %q{moonwolf@moonwolf.com}
|
11
|
-
s.homepage = %q{http://rwiki.moonwolf.com/rw-cgi.cgi?cmd=view;name=fcgi}
|
12
|
-
s.autorequire = %q{fcgi}
|
13
|
-
s.extensions = ["extconf.rb"]
|
14
|
-
s.has_rdoc = true
|
15
|
-
s.extra_rdoc_files = ["README"]
|
16
|
-
end
|