ruby-lsapi 4.4 → 5.0
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 +5 -5
- data/ext/lsapi/lsapidef.h +13 -13
- data/ext/lsapi/lsapilib.c +838 -197
- data/ext/lsapi/lsapilib.h +61 -16
- data/ext/lsapi/lsruby.c +35 -4
- data/lsapi.gemspec +2 -2
- metadata +3 -3
data/ext/lsapi/lsapilib.h
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
/*
|
2
|
-
Copyright (c) 2002-
|
2
|
+
Copyright (c) 2002-2018, Lite Speed Technologies Inc.
|
3
3
|
All rights reserved.
|
4
4
|
|
5
5
|
Redistribution and use in source and binary forms, with or without
|
6
6
|
modification, are permitted provided that the following conditions are
|
7
|
-
met:
|
7
|
+
met:
|
8
8
|
|
9
9
|
* Redistributions of source code must retain the above copyright
|
10
|
-
notice, this list of conditions and the following disclaimer.
|
10
|
+
notice, this list of conditions and the following disclaimer.
|
11
11
|
* Redistributions in binary form must reproduce the above
|
12
12
|
copyright notice, this list of conditions and the following
|
13
13
|
disclaimer in the documentation and/or other materials provided
|
14
|
-
with the distribution.
|
14
|
+
with the distribution.
|
15
15
|
* Neither the name of the Lite Speed Technologies Inc nor the
|
16
16
|
names of its contributors may be used to endorse or promote
|
17
17
|
products derived from this software without specific prior
|
18
|
-
written permission.
|
18
|
+
written permission.
|
19
19
|
|
20
20
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
21
21
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
@@ -27,7 +27,7 @@ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
27
27
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
28
28
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
29
29
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
31
|
*/
|
32
32
|
|
33
33
|
|
@@ -52,8 +52,8 @@ struct LSAPI_key_value_pair
|
|
52
52
|
int valLen;
|
53
53
|
};
|
54
54
|
|
55
|
-
|
56
|
-
#define LSAPI_MAX_RESP_HEADERS
|
55
|
+
struct lsapi_child_status;
|
56
|
+
#define LSAPI_MAX_RESP_HEADERS 1000
|
57
57
|
|
58
58
|
typedef struct lsapi_request
|
59
59
|
{
|
@@ -65,7 +65,7 @@ typedef struct lsapi_request
|
|
65
65
|
|
66
66
|
char * m_pReqBuf;
|
67
67
|
int m_reqBufSize;
|
68
|
-
|
68
|
+
|
69
69
|
char * m_pRespBuf;
|
70
70
|
char * m_pRespBufEnd;
|
71
71
|
char * m_pRespBufPos;
|
@@ -73,12 +73,13 @@ typedef struct lsapi_request
|
|
73
73
|
char * m_pRespHeaderBuf;
|
74
74
|
char * m_pRespHeaderBufEnd;
|
75
75
|
char * m_pRespHeaderBufPos;
|
76
|
+
struct lsapi_child_status * child_status;
|
76
77
|
|
77
78
|
|
78
79
|
struct iovec * m_pIovec;
|
79
80
|
struct iovec * m_pIovecEnd;
|
80
81
|
struct iovec * m_pIovecCur;
|
81
|
-
struct iovec * m_pIovecToWrite;
|
82
|
+
struct iovec * m_pIovecToWrite;
|
82
83
|
|
83
84
|
struct lsapi_packet_header * m_respPktHeaderEnd;
|
84
85
|
|
@@ -90,7 +91,7 @@ typedef struct lsapi_request
|
|
90
91
|
|
91
92
|
struct lsapi_http_header_index * m_pHeaderIndex;
|
92
93
|
struct lsapi_header_offset * m_pUnknownHeader;
|
93
|
-
|
94
|
+
|
94
95
|
char * m_pScriptFile;
|
95
96
|
char * m_pScriptName;
|
96
97
|
char * m_pQueryString;
|
@@ -102,9 +103,9 @@ typedef struct lsapi_request
|
|
102
103
|
off_t m_reqBodyRead;
|
103
104
|
int m_bufProcessed;
|
104
105
|
int m_bufRead;
|
105
|
-
|
106
|
+
|
106
107
|
struct lsapi_packet_header m_respPktHeader[5];
|
107
|
-
|
108
|
+
|
108
109
|
struct lsapi_resp_header m_respHeader;
|
109
110
|
short m_respHeaderLen[LSAPI_MAX_RESP_HEADERS];
|
110
111
|
void * m_pAppData;
|
@@ -150,7 +151,6 @@ int LSAPI_ForeachSpecialEnv_r( LSAPI_Request * pReq,
|
|
150
151
|
LSAPI_CB_EnvHandler fn, void * arg );
|
151
152
|
|
152
153
|
char * LSAPI_GetEnv_r( LSAPI_Request * pReq, const char * name );
|
153
|
-
|
154
154
|
|
155
155
|
ssize_t LSAPI_ReadReqBody_r( LSAPI_Request * pReq, char * pBuf, size_t len );
|
156
156
|
|
@@ -171,7 +171,7 @@ int LSAPI_Flush_r( LSAPI_Request * pReq );
|
|
171
171
|
|
172
172
|
int LSAPI_AppendRespHeader_r( LSAPI_Request * pReq, const char * pBuf, int len );
|
173
173
|
|
174
|
-
int LSAPI_AppendRespHeader2_r( LSAPI_Request * pReq, const char * pHeaderName,
|
174
|
+
int LSAPI_AppendRespHeader2_r( LSAPI_Request * pReq, const char * pHeaderName,
|
175
175
|
const char * pHeaderValue );
|
176
176
|
|
177
177
|
int LSAPI_ErrResponse_r( LSAPI_Request * pReq, int code, const char ** pRespHeaders,
|
@@ -248,6 +248,9 @@ static inline off_t LSAPI_GetReqBodyRemain_r( LSAPI_Request * pReq )
|
|
248
248
|
}
|
249
249
|
|
250
250
|
|
251
|
+
int LSAPI_End_Response_r(LSAPI_Request * pReq);
|
252
|
+
|
253
|
+
|
251
254
|
|
252
255
|
int LSAPI_Is_Listen(void);
|
253
256
|
|
@@ -313,7 +316,7 @@ static inline ssize_t LSAPI_Write( const char * pBuf, ssize_t len )
|
|
313
316
|
|
314
317
|
static inline ssize_t LSAPI_sendfile( int fdIn, off_t* off, size_t size )
|
315
318
|
{
|
316
|
-
return LSAPI_sendfile_r(&g_req, fdIn, off, size );
|
319
|
+
return LSAPI_sendfile_r(&g_req, fdIn, off, size );
|
317
320
|
}
|
318
321
|
|
319
322
|
static inline ssize_t LSAPI_Write_Stderr( const char * pBuf, ssize_t len )
|
@@ -331,6 +334,9 @@ static inline int LSAPI_SetRespStatus( int code )
|
|
331
334
|
static inline int LSAPI_ErrResponse( int code, const char ** pRespHeaders, const char * pBody, int bodyLen )
|
332
335
|
{ return LSAPI_ErrResponse_r( &g_req, code, pRespHeaders, pBody, bodyLen ); }
|
333
336
|
|
337
|
+
static inline int LSAPI_End_Response(void)
|
338
|
+
{ return LSAPI_End_Response_r( &g_req ); }
|
339
|
+
|
334
340
|
int LSAPI_IsRunning(void);
|
335
341
|
|
336
342
|
int LSAPI_CreateListenSock( const char * pBind, int backlog );
|
@@ -343,6 +349,8 @@ void LSAPI_Set_Server_fd( int fd );
|
|
343
349
|
|
344
350
|
int LSAPI_Prefork_Accept_r( LSAPI_Request * pReq );
|
345
351
|
|
352
|
+
void LSAPI_No_Check_ppid(void);
|
353
|
+
|
346
354
|
void LSAPI_Set_Max_Reqs( int reqs );
|
347
355
|
|
348
356
|
void LSAPI_Set_Max_Idle( int secs );
|
@@ -363,6 +371,43 @@ int LSAPI_Get_Slow_Req_Msecs(void);
|
|
363
371
|
|
364
372
|
int LSAPI_is_suEXEC_Daemon(void);
|
365
373
|
|
374
|
+
int LSAPI_Set_Restored_Parent_Pid(int pid);
|
375
|
+
|
376
|
+
typedef void (*LSAPI_On_Timer_pf)(int *forked_child_pid);
|
377
|
+
void LSAPI_Register_Pgrp_Timer_Callback(LSAPI_On_Timer_pf);
|
378
|
+
|
379
|
+
int LSAPI_Inc_Req_Processed(int cnt);
|
380
|
+
|
381
|
+
int LSAPI_Accept_Before_Fork(LSAPI_Request * pReq);
|
382
|
+
|
383
|
+
int LSAPI_Postfork_Child(LSAPI_Request * pReq);
|
384
|
+
|
385
|
+
int LSAPI_Postfork_Parent(LSAPI_Request * pReq);
|
386
|
+
|
387
|
+
#define LSAPI_LOG_LEVEL_BITS 0xff
|
388
|
+
#define LSAPI_LOG_FLAG_NONE 0
|
389
|
+
#define LSAPI_LOG_FLAG_DEBUG 1
|
390
|
+
#define LSAPI_LOG_FLAG_INFO 2
|
391
|
+
#define LSAPI_LOG_FLAG_NOTICE 3
|
392
|
+
#define LSAPI_LOG_FLAG_WARN 4
|
393
|
+
#define LSAPI_LOG_FLAG_ERROR 5
|
394
|
+
#define LSAPI_LOG_FLAG_CRIT 6
|
395
|
+
#define LSAPI_LOG_FLAG_FATAL 7
|
396
|
+
|
397
|
+
#define LSAPI_LOG_TIMESTAMP_BITS (0xff00)
|
398
|
+
#define LSAPI_LOG_TIMESTAMP_FULL (0x100)
|
399
|
+
#define LSAPI_LOG_TIMESTAMP_HMS (0x200)
|
400
|
+
#define LSAPI_LOG_TIMESTAMP_STDERR (0x400)
|
401
|
+
|
402
|
+
#define LSAPI_LOG_PID (0x10000)
|
403
|
+
|
404
|
+
void LSAPI_Log(int flag, const char * fmt, ...)
|
405
|
+
#if __GNUC__
|
406
|
+
__attribute__((format(printf, 2, 3)))
|
407
|
+
#endif
|
408
|
+
;
|
409
|
+
|
410
|
+
|
366
411
|
#if defined (c_plusplus) || defined (__cplusplus)
|
367
412
|
}
|
368
413
|
#endif
|
data/ext/lsapi/lsruby.c
CHANGED
@@ -209,6 +209,30 @@ static VALUE lsapi_s_accept( VALUE self )
|
|
209
209
|
}
|
210
210
|
}
|
211
211
|
|
212
|
+
|
213
|
+
static VALUE lsapi_s_accept_new_conn(VALUE self)
|
214
|
+
{
|
215
|
+
if (LSAPI_Accept_Before_Fork(&g_req) == -1 )
|
216
|
+
return Qnil;
|
217
|
+
else
|
218
|
+
return s_req;
|
219
|
+
}
|
220
|
+
|
221
|
+
|
222
|
+
static VALUE lsapi_s_postfork_child(VALUE self)
|
223
|
+
{
|
224
|
+
LSAPI_Postfork_Child(&g_req);
|
225
|
+
return s_req;
|
226
|
+
}
|
227
|
+
|
228
|
+
|
229
|
+
static VALUE lsapi_s_postfork_parent(VALUE self)
|
230
|
+
{
|
231
|
+
LSAPI_Postfork_Parent(&g_req);
|
232
|
+
return s_req;
|
233
|
+
}
|
234
|
+
|
235
|
+
|
212
236
|
/*
|
213
237
|
* static int chdir_file( const char * pFile )
|
214
238
|
* {
|
@@ -482,15 +506,19 @@ static int createBodyBuf()
|
|
482
506
|
{
|
483
507
|
return 1;
|
484
508
|
}
|
485
|
-
ftruncate(fd, s_body.bodyLen)
|
509
|
+
if (ftruncate(fd, s_body.bodyLen) == 0)
|
510
|
+
{
|
511
|
+
perror("ftruncate() failed. \n");
|
512
|
+
close(fd);
|
513
|
+
return 1;
|
514
|
+
}
|
486
515
|
s_body.bodyBuf = mmap(NULL, s_body.bodyLen, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
487
516
|
if (s_body.bodyBuf == MAP_FAILED)
|
488
517
|
{
|
489
518
|
perror("File mapping failed. \n");
|
490
519
|
close(fd);
|
491
520
|
return 1;
|
492
|
-
}
|
493
|
-
|
521
|
+
}
|
494
522
|
close(fd); //close since needn't it anymore
|
495
523
|
}
|
496
524
|
else
|
@@ -823,7 +851,10 @@ void Init_lsapi()
|
|
823
851
|
|
824
852
|
cLSAPI = rb_define_class("LSAPI", rb_cObject);
|
825
853
|
rb_define_singleton_method(cLSAPI, "accept", lsapi_s_accept, 0);
|
826
|
-
|
854
|
+
rb_define_singleton_method(cLSAPI, "accept_new_connection", lsapi_s_accept_new_conn, 0);
|
855
|
+
rb_define_singleton_method(cLSAPI, "postfork_child", lsapi_s_postfork_child, 0);
|
856
|
+
rb_define_singleton_method(cLSAPI, "postfork_parent", lsapi_s_postfork_parent, 0);
|
857
|
+
|
827
858
|
rb_define_method(cLSAPI, "process", lsapi_process, 0 );
|
828
859
|
/* rb_define_method(cLSAPI, "initialize", lsapi_initialize, 0); */
|
829
860
|
rb_define_method(cLSAPI, "putc", lsapi_putc, 1);
|
data/lsapi.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{ruby-lsapi}
|
3
|
-
s.version = "
|
4
|
-
s.date = %q{
|
3
|
+
s.version = "5.0"
|
4
|
+
s.date = %q{2020-05-15}
|
5
5
|
s.description = "This is a ruby extension for fast communication with LiteSpeed Web Server."
|
6
6
|
s.summary = %q{A ruby extension for fast communication with LiteSpeed Web Server.}
|
7
7
|
s.has_rdoc = false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-lsapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '5.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LiteSpeed Technologies Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: This is a ruby extension for fast communication with LiteSpeed Web Server.
|
14
14
|
email: info@litespeedtech.com
|
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
49
|
version: '0'
|
50
50
|
requirements: []
|
51
51
|
rubyforge_project: ruby-lsapi
|
52
|
-
rubygems_version: 2.2
|
52
|
+
rubygems_version: 2.7.6.2
|
53
53
|
signing_key:
|
54
54
|
specification_version: 4
|
55
55
|
summary: A ruby extension for fast communication with LiteSpeed Web Server.
|