ruby-lsapi 2.8 → 2.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.
data/ext/lsapi/lsapidef.h CHANGED
@@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
31
  */
32
32
 
33
33
  /***************************************************************************
34
- $Id: lsapidef.h,v 1.14 2005/09/29 23:51:06 gwang Exp $
34
+ $Id: lsapidef.h,v 1.15 2008/01/03 18:31:50 gwang Exp $
35
35
  -------------------
36
36
  begin : Thu Feb 10 2005
37
37
  author : George Wang
@@ -79,9 +79,9 @@ enum
79
79
  #define LSAPI_SOCK_FILENO 0
80
80
 
81
81
  #define LSAPI_VERSION_B0 'L'
82
- #define LSAPI_VERSION_B1 'S'
82
+ #define LSAPI_VERSION_B1 'S'
83
83
 
84
- //Values for m_flag in lsapi_packet_header
84
+ /* Values for m_flag in lsapi_packet_header */
85
85
  #define LSAPI_ENDIAN_LITTLE 0
86
86
  #define LSAPI_ENDIAN_BIG 1
87
87
  #define LSAPI_ENDIAN_BIT 1
@@ -92,7 +92,7 @@ enum
92
92
  #define LSAPI_ENDIAN LSAPI_ENDIAN_BIG
93
93
  #endif
94
94
 
95
- //Values for m_type in lsapi_packet_header
95
+ /* Values for m_type in lsapi_packet_header */
96
96
  #define LSAPI_BEGIN_REQUEST 1
97
97
  #define LSAPI_ABORT_REQUEST 2
98
98
  #define LSAPI_RESP_HEADER 3
@@ -111,24 +111,26 @@ enum
111
111
 
112
112
  struct lsapi_packet_header
113
113
  {
114
- char m_versionB0; //LSAPI protocol version
114
+ char m_versionB0; /* LSAPI protocol version */
115
115
  char m_versionB1;
116
116
  char m_type;
117
117
  char m_flag;
118
118
  union
119
119
  {
120
- int32_t m_iLen; //include this header
120
+ int32_t m_iLen; /* include this header */
121
121
  char m_bytes[4];
122
122
  }m_packetLen;
123
123
  };
124
124
 
125
- // LSAPI request header packet
126
- //
127
- // 1. struct lsapi_req_header
128
- // 2. struct lsapi_http_header_index
129
- // 3. lsapi_header_offset * unknownHeaders
130
- // 4. org http request header
131
- // 5. request body if available
125
+ /*
126
+ LSAPI request header packet
127
+
128
+ 1. struct lsapi_req_header
129
+ 2. struct lsapi_http_header_index
130
+ 3. lsapi_header_offset * unknownHeaders
131
+ 4. org http request header
132
+ 5. request body if available
133
+ */
132
134
 
133
135
  struct lsapi_req_header
134
136
  {
@@ -136,9 +138,9 @@ struct lsapi_req_header
136
138
 
137
139
  int32_t m_httpHeaderLen;
138
140
  int32_t m_reqBodyLen;
139
- int32_t m_scriptFileOff; //path to the script file.
140
- int32_t m_scriptNameOff; //decrypted URI, without pathinfo,
141
- int32_t m_queryStringOff; //Query string inside env
141
+ int32_t m_scriptFileOff; /* path to the script file. */
142
+ int32_t m_scriptNameOff; /* decrypted URI, without pathinfo, */
143
+ int32_t m_queryStringOff; /* Query string inside env */
142
144
  int32_t m_requestMethodOff;
143
145
  int32_t m_cntUnknownHeaders;
144
146
  int32_t m_cntEnv;
data/ext/lsapi/lsapilib.c CHANGED
@@ -73,7 +73,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
73
73
  static int g_inited = 0;
74
74
  static int g_running = 1;
75
75
  static int s_ppid;
76
- LSAPI_Request g_req;
76
+ LSAPI_Request g_req = { -1, -1 };
77
77
 
78
78
  void Flush_RespBuf_r( LSAPI_Request * pReq );
79
79
 
@@ -155,7 +155,7 @@ static void lsapi_signal(int signo, sighandler_t handler)
155
155
  static inline void lsapi_buildPacketHeader( struct lsapi_packet_header * pHeader,
156
156
  char type, int len )
157
157
  {
158
- pHeader->m_versionB0 = LSAPI_VERSION_B0; //LSAPI protocol version
158
+ pHeader->m_versionB0 = LSAPI_VERSION_B0; /* LSAPI protocol version */
159
159
  pHeader->m_versionB1 = LSAPI_VERSION_B1;
160
160
  pHeader->m_type = type;
161
161
  pHeader->m_flag = LSAPI_ENDIAN;
@@ -186,25 +186,27 @@ static inline int lsapi_read( int fd, void * pBuf, int len )
186
186
  }
187
187
  }
188
188
 
189
- //static int lsapi_write( int fd, const void * pBuf, int len )
190
- //{
191
- // int ret;
192
- // const char * pCur;
193
- // const char * pEnd;
194
- // if ( len == 0 )
195
- // return 0;
196
- // pCur = (const char *)pBuf;
197
- // pEnd = pCur + len;
198
- // while( g_running && (pCur < pEnd) )
199
- // {
200
- // ret = write( fd, pCur, pEnd - pCur );
201
- // if ( ret >= 0)
202
- // pCur += ret;
203
- // else if (( ret == -1 )&&( errno != EINTR ))
204
- // return ret;
205
- // }
206
- // return pCur - (const char *)pBuf;
207
- //}
189
+ /*
190
+ static int lsapi_write( int fd, const void * pBuf, int len )
191
+ {
192
+ int ret;
193
+ const char * pCur;
194
+ const char * pEnd;
195
+ if ( len == 0 )
196
+ return 0;
197
+ pCur = (const char *)pBuf;
198
+ pEnd = pCur + len;
199
+ while( g_running && (pCur < pEnd) )
200
+ {
201
+ ret = write( fd, pCur, pEnd - pCur );
202
+ if ( ret >= 0)
203
+ pCur += ret;
204
+ else if (( ret == -1 )&&( errno != EINTR ))
205
+ return ret;
206
+ }
207
+ return pCur - (const char *)pBuf;
208
+ }
209
+ */
208
210
 
209
211
  static int lsapi_writev( int fd, struct iovec ** pVec, int count, int totalLen )
210
212
  {
@@ -250,18 +252,19 @@ static int lsapi_writev( int fd, struct iovec ** pVec, int count, int totalLen )
250
252
  return totalLen - left;
251
253
  }
252
254
 
253
- //static int getTotalLen( struct iovec * pVec, int count )
254
- //{
255
- // struct iovec * pEnd = pVec + count;
256
- // int total = 0;
257
- // while( pVec < pEnd )
258
- // {
259
- // total += pVec->iov_len;
260
- // ++pVec;
261
- // }
262
- // return total;
263
- //}
264
-
255
+ /*
256
+ static int getTotalLen( struct iovec * pVec, int count )
257
+ {
258
+ struct iovec * pEnd = pVec + count;
259
+ int total = 0;
260
+ while( pVec < pEnd )
261
+ {
262
+ total += pVec->iov_len;
263
+ ++pVec;
264
+ }
265
+ return total;
266
+ }
267
+ */
265
268
 
266
269
  static inline int allocateBuf( LSAPI_Request * pReq, int size )
267
270
  {
@@ -677,7 +680,7 @@ static struct lsapi_packet_header finish = {'L', 'S',
677
680
 
678
681
  int LSAPI_Finish_r( LSAPI_Request * pReq )
679
682
  {
680
- //finish req body
683
+ /* finish req body */
681
684
  if ( !pReq )
682
685
  return -1;
683
686
  if (pReq->m_reqState)
@@ -769,6 +772,8 @@ static int readBodyToReqBuf( LSAPI_Request * pReq )
769
772
 
770
773
  int LSAPI_ReqBodyGetChar_r( LSAPI_Request * pReq )
771
774
  {
775
+ if (!pReq || (pReq->m_fd ==-1) )
776
+ return EOF;
772
777
  if ( pReq->m_bufProcessed >= pReq->m_bufRead )
773
778
  {
774
779
  if ( readBodyToReqBuf( pReq ) <= 0 )
@@ -788,7 +793,7 @@ int LSAPI_ReqBodyGetLine_r( LSAPI_Request * pReq, char * pBuf, int bufLen, int *
788
793
  char * pBufCur = pBuf;
789
794
  char * pCur;
790
795
  char * p;
791
- if (!pReq || ( !pBuf )||(bufLen < 0 )|| !getLF )
796
+ if (!pReq || (pReq->m_fd ==-1) ||( !pBuf )||(bufLen < 0 )|| !getLF )
792
797
  return -1;
793
798
  *getLF = 0;
794
799
  while( (left = pBufEnd - pBufCur ) > 0 )
@@ -831,8 +836,8 @@ int LSAPI_ReadReqBody_r( LSAPI_Request * pReq, char * pBuf, int bufLen )
831
836
  {
832
837
  int len;
833
838
  int total;
834
- //char *pOldBuf = pBuf;
835
- if (!pReq || ( !pBuf )||(bufLen < 0 ))
839
+ /* char *pOldBuf = pBuf; */
840
+ if (!pReq || (pReq->m_fd ==-1) || ( !pBuf )||(bufLen < 0 ))
836
841
  return -1;
837
842
 
838
843
  total = pReq->m_pHeader->m_reqBodyLen - pReq->m_reqBodyRead;
@@ -876,11 +881,6 @@ int LSAPI_ReadReqBody_r( LSAPI_Request * pReq, char * pBuf, int bufLen )
876
881
  }
877
882
 
878
883
 
879
- //int LSAPI_Write( const char * pBuf, int len )
880
- //{
881
- // return LSAPI_Write_r( &g_req, pBuf, len );
882
- //}
883
-
884
884
  int LSAPI_Write_r( LSAPI_Request * pReq, const char * pBuf, int len )
885
885
  {
886
886
  struct lsapi_packet_header * pHeader;
@@ -1035,8 +1035,10 @@ int LSAPI_Write_Stderr_r( LSAPI_Request * pReq, const char * pBuf, int len )
1035
1035
  struct iovec iov[2];
1036
1036
  struct iovec *pIov;
1037
1037
 
1038
- if (( !pReq )||( pReq->m_fd == -1 ))
1038
+ if ( !pReq )
1039
1039
  return -1;
1040
+ if (( pReq->m_fd == -1 )||(pReq->m_fd == pReq->m_fdListen ))
1041
+ return write( 2, pBuf, len );
1040
1042
  if ( pReq->m_pRespBufPos != pReq->m_pRespBuf )
1041
1043
  {
1042
1044
  LSAPI_Flush_r( pReq );
@@ -1305,7 +1307,7 @@ int LSAPI_AppendRespHeader_r( LSAPI_Request * pReq, char * pBuf, int len )
1305
1307
  memmove( pReq->m_pRespHeaderBufPos, pBuf, len );
1306
1308
  pReq->m_pRespHeaderBufPos += len;
1307
1309
  *pReq->m_pRespHeaderBufPos++ = 0;
1308
- ++len; //add one byte padding for \0
1310
+ ++len; /* add one byte padding for \0 */
1309
1311
  pReq->m_respHeaderLen[pReq->m_respHeader.m_respInfo.m_cntHeaders] = len;
1310
1312
  ++pReq->m_respHeader.m_respInfo.m_cntHeaders;
1311
1313
  return 0;
@@ -1526,8 +1528,8 @@ int LSAPI_Init_Prefork_Server( int max_children, fn_select_t fp, int avoidFork )
1526
1528
  g_prefork_server->m_iAvoidFork = avoidFork;
1527
1529
  g_prefork_server->m_iMaxChildren = max_children;
1528
1530
 
1529
- g_prefork_server->m_iExtraChildren = ( avoidFork ) ? 0 : max_children / 3 ;
1530
- g_prefork_server->m_iMaxIdleChildren = ( avoidFork ) ? (max_children + 1) : max_children / 3;
1531
+ g_prefork_server->m_iExtraChildren = ( avoidFork ) ? 0 : (max_children / 3) ;
1532
+ g_prefork_server->m_iMaxIdleChildren = ( avoidFork ) ? (max_children + 1) : (max_children / 3);
1531
1533
  g_prefork_server->m_iChildrenMaxIdleTime = 300;
1532
1534
  g_prefork_server->m_iMaxReqProcessTime = 300;
1533
1535
  return 0;
@@ -1715,7 +1717,8 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer, LSAPI_Re
1715
1717
  int wait_secs = 0;
1716
1718
  int ret = 0;
1717
1719
  int pid;
1718
- time_t lastTime = 0, curTime;
1720
+ time_t lastTime = 0;
1721
+ time_t curTime = 0;
1719
1722
  fd_set readfds;
1720
1723
  struct timeval timeout;
1721
1724
 
@@ -1794,7 +1797,7 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer, LSAPI_Re
1794
1797
  {
1795
1798
  if ( errno == EINTR )
1796
1799
  continue;
1797
- //perror( "select()" );
1800
+ /* perror( "select()" ); */
1798
1801
  break;
1799
1802
  }
1800
1803
  else
@@ -1850,7 +1853,7 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer, LSAPI_Re
1850
1853
  }
1851
1854
  sigaction( SIGUSR1, &old_usr1, 0 );
1852
1855
  kill( -getpgrp(), SIGUSR1 );
1853
- lsapi_all_children_must_die(); // Sorry, children ;-)
1856
+ lsapi_all_children_must_die(); /* Sorry, children ;-) */
1854
1857
  return -1;
1855
1858
 
1856
1859
  }
@@ -1997,13 +2000,7 @@ void LSAPI_No_Check_ppid()
1997
2000
  s_ppid = 0;
1998
2001
  }
1999
2002
 
2000
- #if defined(__APPLE__)
2001
- #include <crt_externs.h>
2002
- #define environ (*_NSGetEnviron())
2003
- #else
2004
2003
  extern char ** environ;
2005
- #endif
2006
-
2007
2004
  static void unset_lsapi_envs()
2008
2005
  {
2009
2006
  char **env = environ;
data/ext/lsapi/lsapilib.h CHANGED
@@ -120,7 +120,7 @@ typedef struct lsapi_request
120
120
  extern LSAPI_Request g_req;
121
121
 
122
122
 
123
- //return: >0 continue, ==0 stop, -1 failed
123
+ /* return: >0 continue, ==0 stop, -1 failed */
124
124
  typedef int (*LSAPI_CB_EnvHandler )( const char * pKey, int keyLen,
125
125
  const char * pValue, int valLen, void * arg );
126
126
 
data/ext/lsapi/lsruby.c CHANGED
@@ -1,5 +1,6 @@
1
1
 
2
2
  #include "ruby.h"
3
+ #include "util.h"
3
4
 
4
5
  #include "lsapilib.h"
5
6
  #include <errno.h>
@@ -8,8 +9,9 @@
8
9
  #include <signal.h>
9
10
  #include <sys/socket.h>
10
11
  #include <sys/wait.h>
12
+ #include <unistd.h>
11
13
 
12
- //RUBY_EXTERN VALUE ruby_errinfo;
14
+ /* RUBY_EXTERN VALUE ruby_errinfo; */
13
15
  RUBY_EXTERN VALUE rb_stdin;
14
16
  RUBY_EXTERN VALUE rb_stdout;
15
17
  #if RUBY_VERSION_CODE < 180
@@ -30,7 +32,7 @@ static VALUE env_copy;
30
32
  static VALUE lsapi_env;
31
33
 
32
34
 
33
- static VALUE lsapi_objrefs;
35
+ /* static VALUE lsapi_objrefs; */
34
36
 
35
37
  typedef struct lsapi_data
36
38
  {
@@ -49,15 +51,7 @@ static lsapi_data * s_req_data;
49
51
  static VALUE s_req_stderr = Qnil;
50
52
  static lsapi_data * s_stderr_data;
51
53
 
52
- //static int s_children = 0;
53
- //static int s_cur_children = 0;
54
- //static int s_req_processed = 0;
55
- //static int s_max_reqs = 1000000;
56
- //static int s_max_idle_secs = 60;
57
- //static int s_listenFd = -1;
58
- //static int s_ppid = 0;
59
- //static int s_max_grp_idle_secs = 0;
60
-
54
+ /*
61
55
  static void lsapi_ruby_setenv(const char *name, const char *value)
62
56
  {
63
57
  if (!name) return;
@@ -67,25 +61,25 @@ static void lsapi_ruby_setenv(const char *name, const char *value)
67
61
  else
68
62
  ruby_unsetenv(name);
69
63
  }
70
-
64
+ */
71
65
 
72
66
 
73
67
  static void lsapi_mark( lsapi_data * data )
74
68
  {
75
69
  rb_gc_mark( data->env );
76
70
  }
77
-
71
+ /*
78
72
  static void lsapi_free_data( lsapi_data * data )
79
73
  {
80
- free( data );
74
+ free( data );
81
75
  }
82
-
76
+ */
83
77
  static int add_env_rails( const char * pKey, int keyLen, const char * pValue, int valLen,
84
78
  void * arg )
85
79
  {
86
80
  char * p;
87
81
  int len;
88
- //Fixup some environment variables for rails
82
+ /* Fixup some environment variables for rails */
89
83
  switch( *pKey )
90
84
  {
91
85
  case 'Q':
@@ -102,8 +96,10 @@ static int add_env_rails( const char * pKey, int keyLen, const char * pValue, in
102
96
  if ( p )
103
97
  {
104
98
  len = valLen - ( p - pValue ) - 1;
105
- //valLen = p - pValue;
106
- //*p++ = 0;
99
+ /*
100
+ valLen = p - pValue;
101
+ *p++ = 0;
102
+ */
107
103
  }
108
104
  else
109
105
  {
@@ -134,7 +130,7 @@ static int add_env_rails( const char * pKey, int keyLen, const char * pValue, in
134
130
  break;
135
131
  }
136
132
 
137
- //lsapi_ruby_setenv(pKey, pValue );
133
+ /* lsapi_ruby_setenv(pKey, pValue ); */
138
134
 
139
135
  rb_hash_aset( lsapi_env,rb_tainted_str_new(pKey, keyLen),
140
136
  rb_tainted_str_new(pValue, valLen));
@@ -156,7 +152,7 @@ fn_add_env s_fn_add_env = add_env_no_fix;
156
152
 
157
153
  static void clear_env()
158
154
  {
159
- //rb_funcall( lsapi_env, rb_intern( "clear" ), 0 );
155
+ /* rb_funcall( lsapi_env, rb_intern( "clear" ), 0 ); */
160
156
  rb_funcall( lsapi_env, rb_intern( "replace" ), 1, env_copy );
161
157
  }
162
158
 
@@ -174,11 +170,6 @@ static void setup_cgi_env( lsapi_data * data )
174
170
 
175
171
  static VALUE lsapi_s_accept( VALUE self )
176
172
  {
177
- int fd;
178
- int ret;
179
- int wait_secs;
180
- fd_set readfds;
181
- struct timeval timeout;
182
173
 
183
174
  if ( LSAPI_Prefork_Accept_r( &g_req ) == -1 )
184
175
  return Qnil;
@@ -190,7 +181,7 @@ static VALUE lsapi_s_accept( VALUE self )
190
181
 
191
182
  }
192
183
 
193
-
184
+ /*
194
185
  static int chdir_file( const char * pFile )
195
186
  {
196
187
  char * p = strrchr( pFile, '/' );
@@ -202,6 +193,7 @@ static int chdir_file( const char * pFile )
202
193
  *p = '/';
203
194
  return ret;
204
195
  }
196
+ */
205
197
 
206
198
  static VALUE lsapi_eval_string_wrap(VALUE self, VALUE str)
207
199
  {
@@ -222,12 +214,14 @@ static VALUE lsapi_process( VALUE self )
222
214
  const char * pScriptPath;
223
215
  Data_Get_Struct(self,lsapi_data, data);
224
216
  pScriptPath = LSAPI_GetScriptFileName_r( data->req );
225
- // if ( chdir_file( pScriptPath ) == -1 )
226
- // {
227
- // lsapi_send_error( 404 );
228
- // }
229
- // rb_load_file( pScriptPath );
230
- return Qnil;
217
+ /*
218
+ if ( chdir_file( pScriptPath ) == -1 )
219
+ {
220
+ lsapi_send_error( 404 );
221
+ }
222
+ rb_load_file( pScriptPath );
223
+ */
224
+ return Qnil;
231
225
  }
232
226
 
233
227
 
@@ -248,7 +242,7 @@ static VALUE lsapi_write( VALUE self, VALUE str )
248
242
  lsapi_data *data;
249
243
  int len;
250
244
  Data_Get_Struct(self,lsapi_data, data);
251
- // len = LSAPI_Write_r( data->req, RSTRING(str)->ptr, RSTRING(str)->len );
245
+ /* len = LSAPI_Write_r( data->req, RSTRING(str)->ptr, RSTRING(str)->len ); */
252
246
  if (TYPE(str) != T_STRING)
253
247
  str = rb_obj_as_string(str);
254
248
  len = (*data->fn_write)( data->req, RSTRING(str)->ptr, RSTRING(str)->len );
@@ -361,8 +355,10 @@ static VALUE lsapi_addstr(VALUE out, VALUE str)
361
355
 
362
356
  static VALUE lsapi_flush( VALUE self )
363
357
  {
364
- //lsapi_data *data;
365
- //Data_Get_Struct(self,lsapi_data, data);
358
+ /*
359
+ lsapi_data *data;
360
+ Data_Get_Struct(self,lsapi_data, data);
361
+ */
366
362
  LSAPI_Flush_r( &g_req );
367
363
  return Qnil;
368
364
  }
@@ -370,8 +366,10 @@ static VALUE lsapi_flush( VALUE self )
370
366
  static VALUE lsapi_getc( VALUE self )
371
367
  {
372
368
  int ch;
373
- //lsapi_data *data;
374
- //Data_Get_Struct(self,lsapi_data, data);
369
+ /*
370
+ lsapi_data *data;
371
+ Data_Get_Struct(self,lsapi_data, data);
372
+ */
375
373
  if (rb_safe_level() >= 4 && !OBJ_TAINTED(self))
376
374
  {
377
375
  rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
@@ -412,7 +410,6 @@ static VALUE lsapi_gets( VALUE self )
412
410
  static VALUE lsapi_read(int argc, VALUE *argv, VALUE self)
413
411
  {
414
412
  VALUE str;
415
- //lsapi_data *data;
416
413
  int n;
417
414
  int remain;
418
415
  char buff[8192];
@@ -422,7 +419,6 @@ static VALUE lsapi_read(int argc, VALUE *argv, VALUE self)
422
419
  rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
423
420
  }
424
421
 
425
- //Data_Get_Struct(self, lsapi_data, data);
426
422
 
427
423
  remain = LSAPI_GetReqBodyRemain_r( &g_req );
428
424
  if ( remain <= 0 )
@@ -446,7 +442,7 @@ static VALUE lsapi_read(int argc, VALUE *argv, VALUE self)
446
442
  }
447
443
  else if ( n <= 0 )
448
444
  {
449
- //FIXME: broken connection
445
+ /* FIXME: broken connection */
450
446
  break;
451
447
  }
452
448
  }
@@ -457,45 +453,35 @@ static VALUE lsapi_read(int argc, VALUE *argv, VALUE self)
457
453
 
458
454
  static VALUE lsapi_eof(VALUE self)
459
455
  {
460
- // lsapi_data *data;
461
- //
462
- // if (rb_safe_level() >= 4 && !OBJ_TAINTED(self))
463
- // {
464
- // rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
465
- // }
466
- // Data_Get_Struct(self, lsapi_data, data);
456
+ /*
457
+ lsapi_data *data;
458
+
459
+ if (rb_safe_level() >= 4 && !OBJ_TAINTED(self))
460
+ {
461
+ rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
462
+ }
463
+ Data_Get_Struct(self, lsapi_data, data);
464
+ */
467
465
  return (LSAPI_GetReqBodyRemain( &g_req ) <= 0) ? Qtrue : Qfalse;
468
466
  }
469
467
 
470
468
  static VALUE lsapi_binmode(VALUE self)
471
469
  {
472
- // if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
473
- // rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
474
- // }
475
470
  return self;
476
471
  }
477
472
 
478
473
  static VALUE lsapi_isatty(VALUE self)
479
474
  {
480
- // if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
481
- // rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
482
- // }
483
475
  return Qfalse;
484
476
  }
485
477
 
486
478
  static VALUE lsapi_sync(VALUE self)
487
479
  {
488
- // if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
489
- // rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
490
- // }
491
480
  return Qfalse;
492
481
  }
493
482
 
494
483
  static VALUE lsapi_setsync(VALUE self,VALUE sync)
495
484
  {
496
- // if (rb_safe_level() >= 4 && !OBJ_TAINTED(self)) {
497
- // rb_raise(rb_eSecurityError, "Insecure: operation on untainted IO");
498
- // }
499
485
  return Qfalse;
500
486
  }
501
487
 
@@ -508,10 +494,10 @@ static VALUE lsapi_close(VALUE self)
508
494
 
509
495
  static VALUE lsapi_reopen( int argc, VALUE *argv, VALUE self)
510
496
  {
511
- VALUE orig_verbose; // constant silence hack
497
+ VALUE orig_verbose;
512
498
  if ( self == s_req_stderr )
513
499
  {
514
- //constant silence hack
500
+ /* constant silence hack */
515
501
  orig_verbose = (VALUE)ruby_verbose;
516
502
  ruby_verbose = Qnil;
517
503
 
@@ -530,61 +516,18 @@ static VALUE lsapi_reopen( int argc, VALUE *argv, VALUE self)
530
516
  void Init_lsapi()
531
517
  {
532
518
  VALUE remove_env;
533
- int n = 0;
534
- VALUE orig_verbose; // constant silence hack
519
+ VALUE orig_verbose;
535
520
  char * p;
536
521
 
537
522
  LSAPI_Init();
538
523
 
539
524
  LSAPI_Init_Env_Parameters( rb_thread_select );
540
- /*
541
- p = getenv( "LSAPI_CHILDREN" );
542
- if ( p )
543
- {
544
- n = atoi( p );
545
- ruby_unsetenv( "LSAPI_CHILDREN" );
546
- }
547
- if ( n > 1 )
548
- {
549
- LSAPI_Init_Prefork_Server( n, rb_thread_select );
550
- LSAPI_Set_Server_fd( g_req.m_fdListen );
551
- }
552
-
553
- p = getenv( "LSAPI_MAX_REQS" );
554
- if ( p )
555
- {
556
- n = atoi( p );
557
- if ( n > 0 )
558
- LSAPI_Set_Max_Req( n );
559
- ruby_unsetenv( "LSAPI_MAX_REQS" );
560
- }
561
-
562
- p = getenv( "LSAPI_MAX_IDLE" );
563
- if ( p )
564
- {
565
- n = atoi( p );
566
- LSAPI_Set_Max_Idle( n );
567
- ruby_unsetenv( "LSAPI_MAX_IDLE" );
568
- }
569
-
570
- p = getenv( "LSAPI_PGRP_MAX_IDLE" );
571
- if ( p )
572
- {
573
- LSAPI_Set_Server_Max_Idle_Secs( atoi( p ) );
574
- ruby_unsetenv( "LSAPI_PGRP_MAX_IDLE" );
575
- }
576
-
577
- if ( getenv( "LSAPI_PPID_NO_CHECK" ) )
578
- {
579
- LSAPI_No_Check_ppid();
580
- ruby_unsetenv( "LSAPI_PPID_NO_CHECK" );
581
- }
582
- */
583
525
 
584
526
  p = getenv( "RAILS_ROOT" );
585
527
  if ( p )
586
528
  {
587
- chdir( p );
529
+ if ( chdir( p ) == -1 )
530
+ perror( "chdir()" );
588
531
  }
589
532
  if ( p || getenv( "RAILS_ENV" ) )
590
533
  s_fn_add_env = add_env_rails;
@@ -599,13 +542,13 @@ void Init_lsapi()
599
542
  orig_env = rb_const_get( rb_cObject, rb_intern("ENV") );
600
543
  env_copy = rb_funcall( orig_env, rb_intern( "to_hash" ), 0 );
601
544
 
602
- //tell the garbage collector it is a global variable, do not recycle it.
545
+ /* tell the garbage collector it is a global variable, do not recycle it. */
603
546
  rb_global_variable(&env_copy);
604
547
 
605
548
  rb_hash_aset( env_copy,rb_tainted_str_new("GATEWAY_INTERFACE", 17),
606
549
  rb_tainted_str_new("CGI/1.2", 7));
607
550
 
608
- //Do not need those environments after initialization
551
+ /* Do not need those environments after initialization */
609
552
  remove_env = rb_str_new( "RAILS_ROOT", 10 );
610
553
  rb_funcall( env_copy, rb_intern( "delete" ), 1, remove_env );
611
554
 
@@ -616,7 +559,7 @@ void Init_lsapi()
616
559
  rb_define_singleton_method(cLSAPI, "accept", lsapi_s_accept, 0);
617
560
 
618
561
  rb_define_method(cLSAPI, "process", lsapi_process, 0 );
619
- //rb_define_method(cLSAPI, "initialize", lsapi_initialize, 0);
562
+ /* rb_define_method(cLSAPI, "initialize", lsapi_initialize, 0); */
620
563
  rb_define_method(cLSAPI, "putc", lsapi_putc, 1);
621
564
  rb_define_method(cLSAPI, "write", lsapi_write, 1);
622
565
  rb_define_method(cLSAPI, "print", lsapi_print, -1);
@@ -625,16 +568,16 @@ void Init_lsapi()
625
568
  rb_define_method(cLSAPI, "<<", lsapi_addstr, 1);
626
569
  rb_define_method(cLSAPI, "flush", lsapi_flush, 0);
627
570
  rb_define_method(cLSAPI, "getc", lsapi_getc, 0);
628
- //rb_define_method(cLSAPI, "ungetc", lsapi_ungetc, 1);
571
+ /* rb_define_method(cLSAPI, "ungetc", lsapi_ungetc, 1); */
629
572
  rb_define_method(cLSAPI, "gets", lsapi_gets, 0);
630
573
  rb_define_method(cLSAPI, "read", lsapi_read, -1);
631
574
  rb_define_method(cLSAPI, "eof", lsapi_eof, 0);
632
575
  rb_define_method(cLSAPI, "eof?", lsapi_eof, 0);
633
576
  rb_define_method(cLSAPI, "close", lsapi_close, 0);
634
- // rb_define_method(cLSAPI, "closed?", lsapi_closed, 0);
577
+ /* rb_define_method(cLSAPI, "closed?", lsapi_closed, 0); */
635
578
  rb_define_method(cLSAPI, "binmode", lsapi_binmode, 0);
636
- //rb_define_method(cLSAPI, "isatty", lsapi_isatty, 0);
637
- //rb_define_method(cLSAPI, "tty?", lsapi_isatty, 0);
579
+ rb_define_method(cLSAPI, "isatty", lsapi_isatty, 0);
580
+ rb_define_method(cLSAPI, "tty?", lsapi_isatty, 0);
638
581
  rb_define_method(cLSAPI, "sync", lsapi_sync, 0);
639
582
  rb_define_method(cLSAPI, "sync=", lsapi_setsync, 1);
640
583
  rb_define_method(cLSAPI, "reopen", lsapi_reopen, -1 );
@@ -656,12 +599,12 @@ void Init_lsapi()
656
599
  rb_stderr = s_req_stderr;
657
600
  rb_global_variable(&s_req_stderr );
658
601
 
659
- //constant silence hack
602
+ /* constant silence hack */
660
603
  orig_verbose = (VALUE)ruby_verbose;
661
604
  ruby_verbose = Qnil;
662
605
 
663
606
  lsapi_env = rb_hash_new();
664
- //redefine ENV using a hash table, should be faster than char **environment
607
+ /* redefine ENV using a hash table, should be faster than char **environment */
665
608
  rb_define_global_const("ENV", lsapi_env);
666
609
 
667
610
  rb_define_global_const("STDERR", rb_stderr);
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: ruby-lsapi
5
5
  version: !ruby/object:Gem::Version
6
- version: "2.8"
7
- date: 2007-11-25 00:00:00 -05:00
6
+ version: "2.9"
7
+ date: 2008-01-03 00:00:00 -05:00
8
8
  summary: A ruby extension for fast communication with LiteSpeed Web Server.
9
9
  require_paths:
10
10
  - lib