ruby-lsapi 1.6 → 1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README +3 -3
- data/ext/lsapi/lsruby.c +23 -8
- metadata +1 -1
data/README
CHANGED
@@ -61,9 +61,9 @@ Two new environment variables has been introduced since Ruby LSAPI 1.4:
|
|
61
61
|
|
62
62
|
LSAPI_MAX_REQS=n
|
63
63
|
|
64
|
-
n is the maximum number of requests that a child process can serve.
|
65
|
-
|
66
|
-
|
64
|
+
n is the maximum number of requests that a child process can serve. Default
|
65
|
+
value is 1,000,000. Once that number is reached, the child process will exit
|
66
|
+
automatically. This will help in case of any memory leaks in Rails.
|
67
67
|
|
68
68
|
LSAPI_MAX_IDLE=n
|
69
69
|
|
data/ext/lsapi/lsruby.c
CHANGED
@@ -24,8 +24,11 @@ static VALUE orig_defout;
|
|
24
24
|
|
25
25
|
static VALUE orig_env;
|
26
26
|
|
27
|
+
static VALUE env_copy;
|
28
|
+
|
27
29
|
static VALUE lsapi_env;
|
28
30
|
|
31
|
+
|
29
32
|
static VALUE lsapi_objrefs;
|
30
33
|
|
31
34
|
typedef struct lsapi_data
|
@@ -43,7 +46,7 @@ static lsapi_data * s_req_data;
|
|
43
46
|
static int s_children = 0;
|
44
47
|
static int s_cur_children = 0;
|
45
48
|
static int s_req_processed = 0;
|
46
|
-
static int s_max_reqs =
|
49
|
+
static int s_max_reqs = 1000000;
|
47
50
|
static int s_max_idle_secs = 60;
|
48
51
|
static int s_listenFd = -1;
|
49
52
|
static int s_ppid = 0;
|
@@ -82,14 +85,15 @@ static int add_env( const char * pKey, int keyLen, const char * pValue, int valL
|
|
82
85
|
|
83
86
|
static void clear_env()
|
84
87
|
{
|
85
|
-
rb_funcall( lsapi_env, rb_intern( "clear" ), 0 );
|
88
|
+
//rb_funcall( lsapi_env, rb_intern( "clear" ), 0 );
|
89
|
+
rb_funcall( lsapi_env, rb_intern( "replace" ), 1, env_copy );
|
86
90
|
}
|
87
91
|
|
88
92
|
static void setup_cgi_env( lsapi_data * data )
|
89
93
|
{
|
90
94
|
|
91
95
|
clear_env();
|
92
|
-
|
96
|
+
|
93
97
|
LSAPI_ForeachHeader_r( data->req, add_env, data );
|
94
98
|
LSAPI_ForeachEnv_r( data->req, add_env, data );
|
95
99
|
|
@@ -204,15 +208,15 @@ static int lsapi_fork_child()
|
|
204
208
|
}
|
205
209
|
else if ( pid == -1 )
|
206
210
|
{
|
207
|
-
perror( "fork() failed" );
|
208
|
-
break;
|
211
|
+
perror( "fork() failed, please increase process limit" );
|
209
212
|
}
|
210
213
|
else
|
211
214
|
{
|
212
215
|
++s_cur_children;
|
213
|
-
close( g_req.m_fd );
|
214
|
-
g_req.m_fd = -1;
|
215
216
|
}
|
217
|
+
close( g_req.m_fd );
|
218
|
+
g_req.m_fd = -1;
|
219
|
+
|
216
220
|
}
|
217
221
|
else
|
218
222
|
{
|
@@ -571,11 +575,13 @@ static VALUE lsapi_setsync(VALUE self,VALUE sync)
|
|
571
575
|
|
572
576
|
void Init_lsapi()
|
573
577
|
{
|
578
|
+
VALUE remove_env;
|
574
579
|
int n;
|
575
580
|
char * p = getenv( "LSAPI_CHILDREN" );
|
576
581
|
if ( p )
|
577
582
|
{
|
578
583
|
s_children = atoi( p );
|
584
|
+
unsetenv( "LSAPI_CHILDREN" );
|
579
585
|
}
|
580
586
|
|
581
587
|
p = getenv( "LSAPI_MAX_REQS" );
|
@@ -584,6 +590,7 @@ void Init_lsapi()
|
|
584
590
|
n = atoi( p );
|
585
591
|
if ( n > 0 )
|
586
592
|
s_max_reqs = n;
|
593
|
+
unsetenv( "LSAPI_MAX_REQS" );
|
587
594
|
}
|
588
595
|
|
589
596
|
p = getenv( "LSAPI_MAX_IDLE" );
|
@@ -591,6 +598,7 @@ void Init_lsapi()
|
|
591
598
|
{
|
592
599
|
n = atoi( p );
|
593
600
|
s_max_idle_secs = n;
|
601
|
+
unsetenv( "LSAPI_MAX_IDLE" );
|
594
602
|
}
|
595
603
|
|
596
604
|
orig_stdin = rb_stdin;
|
@@ -599,7 +607,14 @@ void Init_lsapi()
|
|
599
607
|
orig_defout = rb_defout;
|
600
608
|
#endif
|
601
609
|
orig_env = rb_const_get( rb_cObject, rb_intern("ENV") );
|
602
|
-
|
610
|
+
|
611
|
+
env_copy = rb_funcall( orig_env, rb_intern( "to_hash" ), 0 );
|
612
|
+
//Do not need those environments after initialization
|
613
|
+
remove_env = rb_str_new( "RAILS_ROOT", 10 );
|
614
|
+
rb_funcall( env_copy, rb_intern( "delete" ), 1, remove_env );
|
615
|
+
remove_env = rb_str_new( "RAILS_ENV", 9 );
|
616
|
+
rb_funcall( env_copy, rb_intern( "delete" ), 1, remove_env );
|
617
|
+
|
603
618
|
lsapi_env = rb_hash_new();
|
604
619
|
//redefine ENV using a hash table, should be faster than char **environment
|
605
620
|
rb_define_global_const("ENV", lsapi_env);
|
metadata
CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ruby-lsapi
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "1.
|
6
|
+
version: "1.7"
|
7
7
|
date: 2006-08-22 00:00:00 -04:00
|
8
8
|
summary: A ruby extension for fast communication with LiteSpeed Web Server.
|
9
9
|
require_paths:
|