fcgi 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.rdoc +3 -3
- data/VERSION +1 -1
- data/ext/fcgi/fcgi.c +62 -17
- data/fcgi.gemspec +1 -1
- data/lib/fcgi.rb +14 -14
- metadata +6 -8
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: be3a36a6ec0bff57b024aee3540e6c5dd755e314
|
4
|
+
data.tar.gz: 3a6f6137b7012ba0a429a67247c682a933167950
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a3b52ffbf272b3401bfe5f3fb0a0213d730c69eb971ec790144dff1517c157e63aa23c336e6b849749637d0d14cb9f1e69d1b465937295c54505df956866f2cc
|
7
|
+
data.tar.gz: 951c84b5af5de03c78e464f90a4974b537edc68ab020f1ec4a75e879e7413abb657c1ae6e033a74ecfdb788e5f4f2528bae6461114489bce3418fc5a60c745bd
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= fcgi - The New generation of FastCGI library for Ruby.
|
2
2
|
|
3
|
-
Version 0.9.
|
3
|
+
Version 0.9.2
|
4
4
|
|
5
5
|
== Depends
|
6
6
|
|
@@ -12,7 +12,7 @@ Version 0.9.1
|
|
12
12
|
|
13
13
|
== Install
|
14
14
|
|
15
|
-
$ gem install
|
15
|
+
$ gem install fcgi
|
16
16
|
|
17
17
|
== Usage
|
18
18
|
=== Class Method
|
@@ -100,7 +100,7 @@ standard CGI library.
|
|
100
100
|
|
101
101
|
fcgi.c 0.1 Copyright (C) 1998-1999 Network Applied Communication Laboratory, Inc.
|
102
102
|
0.8 Copyright (C) 2002 MoonWolf <moonwolf@moonwolf.com>
|
103
|
-
0.9 Copyright (C) 2013
|
103
|
+
0.9 Copyright (C) 2013 mva <mva@mva.name> Alpha, LLC
|
104
104
|
|
105
105
|
fastcgi.rb 0.7 Copyright (C) 2001 Eli Green
|
106
106
|
fcgi.rb 0.8 Copyright (C) 2002 MoonWolf <moonwolf@moonwolf.com>
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.2
|
data/ext/fcgi/fcgi.c
CHANGED
@@ -35,6 +35,11 @@ static VALUE eFCGIStreamProtocolError;
|
|
35
35
|
static VALUE eFCGIStreamParamsError;
|
36
36
|
static VALUE eFCGIStreamCallSeqError;
|
37
37
|
|
38
|
+
typedef struct fcgi_stream_data {
|
39
|
+
VALUE req;
|
40
|
+
FCGX_Stream *stream;
|
41
|
+
} fcgi_stream_data;
|
42
|
+
|
38
43
|
typedef struct fcgi_data {
|
39
44
|
FCGX_Request *req;
|
40
45
|
VALUE in;
|
@@ -43,9 +48,18 @@ typedef struct fcgi_data {
|
|
43
48
|
VALUE env;
|
44
49
|
} fcgi_data;
|
45
50
|
|
51
|
+
static void fcgi_stream_mark(fcgi_stream_data *stream_data)
|
52
|
+
{
|
53
|
+
rb_gc_mark(stream_data->req);
|
54
|
+
}
|
55
|
+
|
56
|
+
static void fcgi_stream_free(fcgi_stream_data *stream_data)
|
57
|
+
{
|
58
|
+
free(stream_data);
|
59
|
+
}
|
60
|
+
|
46
61
|
static void fcgi_mark(fcgi_data *data)
|
47
62
|
{
|
48
|
-
/* rb_gc_mark(data->req); */
|
49
63
|
rb_gc_mark(data->in);
|
50
64
|
rb_gc_mark(data->out);
|
51
65
|
rb_gc_mark(data->err);
|
@@ -54,6 +68,7 @@ static void fcgi_mark(fcgi_data *data)
|
|
54
68
|
|
55
69
|
static void fcgi_free_req(fcgi_data *data)
|
56
70
|
{
|
71
|
+
FCGX_Free(data->req, 1);
|
57
72
|
free(data->req);
|
58
73
|
free(data);
|
59
74
|
}
|
@@ -74,13 +89,14 @@ static VALUE fcgi_s_accept(VALUE self)
|
|
74
89
|
|
75
90
|
FD_ZERO(&readfds);
|
76
91
|
FD_SET(req->listen_sock, &readfds);
|
77
|
-
if (
|
92
|
+
if (select(req->listen_sock+1, &readfds, NULL, NULL, NULL) < 1) {
|
78
93
|
return Qnil;
|
79
94
|
}
|
80
95
|
|
81
96
|
status = FCGX_Accept_r(req);
|
82
97
|
if (status >= 0) {
|
83
98
|
fcgi_data *data;
|
99
|
+
fcgi_stream_data *stream_data;
|
84
100
|
char **env;
|
85
101
|
VALUE obj,key, value;
|
86
102
|
char *pkey,*pvalue;
|
@@ -96,9 +112,15 @@ static VALUE fcgi_s_accept(VALUE self)
|
|
96
112
|
|
97
113
|
obj = Data_Make_Struct(self, fcgi_data, fcgi_mark, fcgi_free_req, data);
|
98
114
|
data->req = req;
|
99
|
-
data->in
|
100
|
-
|
101
|
-
|
115
|
+
data->in = Data_Make_Struct(cFCGIStream, fcgi_stream_data, fcgi_stream_mark, fcgi_stream_free, stream_data);
|
116
|
+
stream_data->stream = req->in;
|
117
|
+
stream_data->req = obj;
|
118
|
+
data->out = Data_Make_Struct(cFCGIStream, fcgi_stream_data, fcgi_stream_mark, fcgi_stream_free, stream_data);
|
119
|
+
stream_data->stream = req->out;
|
120
|
+
stream_data->req = obj;
|
121
|
+
data->err = Data_Make_Struct(cFCGIStream, fcgi_stream_data, fcgi_stream_mark, fcgi_stream_free, stream_data);
|
122
|
+
stream_data->stream = req->err;
|
123
|
+
stream_data->req = obj;
|
102
124
|
data->env = rb_hash_new();
|
103
125
|
env = req->envp;
|
104
126
|
for (; *env; env++) {
|
@@ -115,6 +137,8 @@ static VALUE fcgi_s_accept(VALUE self)
|
|
115
137
|
|
116
138
|
return obj;
|
117
139
|
} else {
|
140
|
+
FCGX_Free(req, 1);
|
141
|
+
free(req);
|
118
142
|
return Qnil;
|
119
143
|
}
|
120
144
|
}
|
@@ -173,9 +197,24 @@ static VALUE fcgi_env(VALUE self)
|
|
173
197
|
static VALUE fcgi_finish(VALUE self)
|
174
198
|
{
|
175
199
|
fcgi_data *data;
|
200
|
+
fcgi_stream_data *stream_data;
|
176
201
|
|
177
202
|
Data_Get_Struct(self, fcgi_data, data);
|
178
203
|
|
204
|
+
if (Qnil != data->in) {
|
205
|
+
Data_Get_Struct(data->in, fcgi_stream_data, stream_data);
|
206
|
+
stream_data->req = Qnil; stream_data->stream = NULL;
|
207
|
+
}
|
208
|
+
if (Qnil != data->out) {
|
209
|
+
Data_Get_Struct(data->out, fcgi_stream_data, stream_data);
|
210
|
+
stream_data->req = Qnil; stream_data->stream = NULL;
|
211
|
+
}
|
212
|
+
if (Qnil != data->err) {
|
213
|
+
Data_Get_Struct(data->err, fcgi_stream_data, stream_data);
|
214
|
+
stream_data->req = Qnil; stream_data->stream = NULL;
|
215
|
+
}
|
216
|
+
|
217
|
+
data->in = data->out = data->err = Qnil;
|
179
218
|
FCGX_Finish_r(data->req);
|
180
219
|
|
181
220
|
return Qtrue;
|
@@ -186,8 +225,7 @@ static VALUE fcgi_finish(VALUE self)
|
|
186
225
|
extern int errno; \
|
187
226
|
if (err) {\
|
188
227
|
if (err > 0) {\
|
189
|
-
|
190
|
-
rb_sys_fail(NULL);\
|
228
|
+
rb_raise(eFCGIStreamError, "unknown error (syscall error)");\
|
191
229
|
}\
|
192
230
|
else {\
|
193
231
|
switch (err) {\
|
@@ -211,13 +249,20 @@ static VALUE fcgi_finish(VALUE self)
|
|
211
249
|
}\
|
212
250
|
}
|
213
251
|
|
252
|
+
#define Data_Get_Stream(value, stream) do {\
|
253
|
+
fcgi_stream_data* _fsd;\
|
254
|
+
Data_Get_Struct(value, fcgi_stream_data, _fsd);\
|
255
|
+
if (NULL == (stream = _fsd->stream))\
|
256
|
+
rb_raise(eFCGIStreamError, "stream invalid as fastcgi request is already finished");\
|
257
|
+
} while (0)
|
258
|
+
|
214
259
|
static VALUE fcgi_stream_putc(VALUE self, VALUE ch)
|
215
260
|
{
|
216
261
|
FCGX_Stream *stream;
|
217
262
|
int c;
|
218
263
|
|
219
264
|
rb_secure(4);
|
220
|
-
|
265
|
+
Data_Get_Stream(self, stream);
|
221
266
|
if ((c = FCGX_PutChar(NUM2INT(ch), stream)) == EOF)
|
222
267
|
CHECK_STREAM_ERROR(stream);
|
223
268
|
return INT2NUM(c);
|
@@ -229,7 +274,7 @@ static VALUE fcgi_stream_write(VALUE self, VALUE str)
|
|
229
274
|
int len;
|
230
275
|
|
231
276
|
rb_secure(4);
|
232
|
-
|
277
|
+
Data_Get_Stream(self, stream);
|
233
278
|
str = rb_obj_as_string(str);
|
234
279
|
len = FCGX_PutStr(RSTRING_PTR(str), RSTRING_LEN(str), stream);
|
235
280
|
if (len == EOF) CHECK_STREAM_ERROR(stream);
|
@@ -335,7 +380,7 @@ static VALUE fcgi_stream_flush(VALUE self)
|
|
335
380
|
{
|
336
381
|
FCGX_Stream *stream;
|
337
382
|
|
338
|
-
|
383
|
+
Data_Get_Stream(self, stream);
|
339
384
|
if (FCGX_FFlush(stream) == EOF)
|
340
385
|
CHECK_STREAM_ERROR(stream);
|
341
386
|
return Qnil;
|
@@ -346,7 +391,7 @@ static VALUE fcgi_stream_getc(VALUE self)
|
|
346
391
|
FCGX_Stream *stream;
|
347
392
|
int c;
|
348
393
|
|
349
|
-
|
394
|
+
Data_Get_Stream(self, stream);
|
350
395
|
if ((c = FCGX_GetChar(stream)) == EOF) {
|
351
396
|
CHECK_STREAM_ERROR(stream);
|
352
397
|
return Qnil;
|
@@ -364,7 +409,7 @@ static VALUE fcgi_stream_ungetc(VALUE self, VALUE ch)
|
|
364
409
|
if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
|
365
410
|
rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
|
366
411
|
}
|
367
|
-
|
412
|
+
Data_Get_Stream(self, stream);
|
368
413
|
c = FCGX_UnGetChar(NUM2INT(ch), stream);
|
369
414
|
CHECK_STREAM_ERROR(stream);
|
370
415
|
return INT2NUM(c);
|
@@ -380,7 +425,7 @@ static VALUE fcgi_stream_gets(VALUE self) {
|
|
380
425
|
rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
|
381
426
|
}
|
382
427
|
|
383
|
-
|
428
|
+
Data_Get_Stream(self, stream);
|
384
429
|
|
385
430
|
for (;;) {
|
386
431
|
if (FCGX_GetLine(buff, BUFSIZ, stream) == NULL) {
|
@@ -407,7 +452,7 @@ static VALUE fcgi_stream_read(int argc, VALUE *argv, VALUE self)
|
|
407
452
|
rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
|
408
453
|
}
|
409
454
|
|
410
|
-
|
455
|
+
Data_Get_Stream(self, stream);
|
411
456
|
|
412
457
|
if (argc==0) {
|
413
458
|
buff = ALLOC_N(char, 16384);
|
@@ -459,7 +504,7 @@ static VALUE fcgi_stream_eof(VALUE self)
|
|
459
504
|
if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
|
460
505
|
rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
|
461
506
|
}
|
462
|
-
|
507
|
+
Data_Get_Stream(self, stream);
|
463
508
|
return FCGX_HasSeenEOF(stream) ? Qtrue : Qfalse;
|
464
509
|
}
|
465
510
|
|
@@ -470,7 +515,7 @@ static VALUE fcgi_stream_close(VALUE self)
|
|
470
515
|
if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
|
471
516
|
rb_raise(rb_eSecurityError, "Insecure: can't close");
|
472
517
|
}
|
473
|
-
|
518
|
+
Data_Get_Stream(self, stream);
|
474
519
|
if (FCGX_FClose(stream) == EOF)
|
475
520
|
CHECK_STREAM_ERROR(stream);
|
476
521
|
return Qnil;
|
@@ -480,7 +525,7 @@ static VALUE fcgi_stream_closed(VALUE self)
|
|
480
525
|
{
|
481
526
|
FCGX_Stream *stream;
|
482
527
|
|
483
|
-
|
528
|
+
Data_Get_Stream(self, stream);
|
484
529
|
return stream->isClosed ? Qtrue : Qfalse;
|
485
530
|
}
|
486
531
|
|
data/fcgi.gemspec
CHANGED
data/lib/fcgi.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
=begin
|
2
2
|
|
3
|
-
fcgi.rb 0.9.
|
3
|
+
fcgi.rb 0.9.2 - fcgi.so compatible pure-ruby FastCGI library
|
4
4
|
|
5
5
|
fastcgi.rb Copyright (C) 2001 Eli Green
|
6
6
|
fcgi.rb Copyright (C) 2002-2003 MoonWolf <moonwolf@moonwolf.com>
|
@@ -18,12 +18,12 @@ begin
|
|
18
18
|
rescue LoadError # Load the pure ruby version instead
|
19
19
|
# At this point we do have STDERR so put it to some good use
|
20
20
|
$stderr.puts "Your FCGI gem does not contain the FCGI shared library, running pure ruby instead"
|
21
|
-
|
21
|
+
|
22
22
|
require 'socket'
|
23
23
|
require 'stringio'
|
24
|
-
|
24
|
+
|
25
25
|
class FCGI
|
26
|
-
|
26
|
+
|
27
27
|
def self.is_cgi?
|
28
28
|
begin
|
29
29
|
s = Socket.for_fd($stdin.fileno)
|
@@ -113,7 +113,7 @@ rescue LoadError # Load the pure ruby version instead
|
|
113
113
|
exit 0 if graceful
|
114
114
|
end
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
def session
|
118
118
|
sock, addr = *@server.accept
|
119
119
|
return unless sock
|
@@ -368,7 +368,7 @@ rescue LoadError # Load the pure ruby version instead
|
|
368
368
|
|
369
369
|
attr_reader :role
|
370
370
|
attr_reader :flags
|
371
|
-
|
371
|
+
|
372
372
|
def make_body
|
373
373
|
[@role, @flags, 0, 0, 0, 0, 0].pack(BODY_FORMAT)
|
374
374
|
end
|
@@ -448,14 +448,14 @@ rescue LoadError # Load the pure ruby version instead
|
|
448
448
|
end
|
449
449
|
result
|
450
450
|
end
|
451
|
-
|
451
|
+
|
452
452
|
def self.read_pair(buf)
|
453
453
|
nlen = read_length(buf)
|
454
454
|
vlen = read_length(buf)
|
455
455
|
[buf.slice!(0, nlen), buf.slice!(0, vlen)]
|
456
456
|
end
|
457
|
-
|
458
|
-
|
457
|
+
|
458
|
+
|
459
459
|
if "".respond_to?(:bytes) # Ruby 1.9 string semantics
|
460
460
|
def self.read_length(buf)
|
461
461
|
if buf[0].bytes.first >> 7 == 0
|
@@ -587,7 +587,7 @@ end # begin
|
|
587
587
|
class FCGI
|
588
588
|
def self.each_cgi(*args)
|
589
589
|
require 'cgi'
|
590
|
-
|
590
|
+
|
591
591
|
eval(<<-EOS,TOPLEVEL_BINDING)
|
592
592
|
class CGI
|
593
593
|
public :env_table
|
@@ -622,17 +622,17 @@ class FCGI
|
|
622
622
|
end # FCGI::CGI class
|
623
623
|
end # FCGI class
|
624
624
|
EOS
|
625
|
-
|
625
|
+
|
626
626
|
if FCGI::is_cgi?
|
627
627
|
yield ::CGI.new(*args)
|
628
628
|
else
|
629
629
|
exit_requested = false
|
630
630
|
FCGI::each do |request|
|
631
|
-
|
631
|
+
|
632
632
|
$stdout, $stderr = request.out, request.err
|
633
|
-
|
633
|
+
|
634
634
|
yield CGI.new(request, *args)
|
635
|
-
|
635
|
+
|
636
636
|
request.finish
|
637
637
|
end
|
638
638
|
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fcgi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
5
|
-
prerelease:
|
4
|
+
version: 0.9.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- mva
|
@@ -38,28 +37,27 @@ files:
|
|
38
37
|
- test/test_fcgi.rb
|
39
38
|
homepage: http://github.com/alphallc/ruby-fcgi-ng
|
40
39
|
licenses: []
|
40
|
+
metadata: {}
|
41
41
|
post_install_message:
|
42
42
|
rdoc_options:
|
43
43
|
- --charset=UTF-8
|
44
44
|
require_paths:
|
45
45
|
- lib
|
46
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
-
none: false
|
48
47
|
requirements:
|
49
|
-
- -
|
48
|
+
- - '>='
|
50
49
|
- !ruby/object:Gem::Version
|
51
50
|
version: '0'
|
52
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
52
|
requirements:
|
55
|
-
- -
|
53
|
+
- - '>='
|
56
54
|
- !ruby/object:Gem::Version
|
57
55
|
version: '0'
|
58
56
|
requirements: []
|
59
57
|
rubyforge_project:
|
60
|
-
rubygems_version:
|
58
|
+
rubygems_version: 2.0.3
|
61
59
|
signing_key:
|
62
|
-
specification_version:
|
60
|
+
specification_version: 4
|
63
61
|
summary: FastCGI library for Ruby.
|
64
62
|
test_files:
|
65
63
|
- test/helper.rb
|