ruby-lsapi 5.0 → 5.1
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 +4 -4
- data/ext/lsapi/lsapilib.c +23 -24
- data/ext/lsapi/lsruby.c +12 -5
- data/lsapi.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 665d989d50ec0e54915439997a1a09c0eb77c6bfdc0e1bf86dc96096b8eaab4a
|
4
|
+
data.tar.gz: 0fc93aa398f8f0bf7ef5b566cbd0504f509d6b3f80eb6a1532f719ab1b296f51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ad0661c05da99577c6a8a0974a49e5621c250b498122b6b8acb045dc1076a1e8413f65af66c3b3c78c169b28ab2180ff72db08339c8f8311059c8086223bfbd
|
7
|
+
data.tar.gz: facafedc4aa6c30e1f7007188d743b1a47c919eef452a17119065e0ce47bee4be551fc017521de61cf9685c901494e042a254216c663ca88ff088bdff206d636
|
data/ext/lsapi/lsapilib.c
CHANGED
@@ -225,8 +225,8 @@ void LSAPI_Log(int flag, const char * fmt, ...)
|
|
225
225
|
{
|
226
226
|
char buf[1024];
|
227
227
|
char *p = buf;
|
228
|
-
if ((flag & LSAPI_LOG_TIMESTAMP_BITS)
|
229
|
-
!(
|
228
|
+
if ((flag & LSAPI_LOG_TIMESTAMP_BITS)
|
229
|
+
&& !(s_stderr_is_pipe))
|
230
230
|
{
|
231
231
|
struct timeval tv;
|
232
232
|
struct tm tm;
|
@@ -253,7 +253,7 @@ void LSAPI_Log(int flag, const char * fmt, ...)
|
|
253
253
|
|
254
254
|
if (flag & LSAPI_LOG_PID)
|
255
255
|
{
|
256
|
-
p += snprintf(p, 100, "[%d] ", s_pid);
|
256
|
+
p += snprintf(p, 100, "[UID:%d][%d] ", getuid(), s_pid);
|
257
257
|
}
|
258
258
|
|
259
259
|
if (p > buf)
|
@@ -275,10 +275,16 @@ void LSAPI_Log(int flag, const char * fmt, ...)
|
|
275
275
|
|
276
276
|
#endif
|
277
277
|
|
278
|
-
#define lsapi_log(...) LSAPI_Log(LSAPI_LOG_TIMESTAMP_FULL|
|
278
|
+
#define lsapi_log(...) LSAPI_Log(LSAPI_LOG_TIMESTAMP_FULL|LSAPI_LOG_PID, __VA_ARGS__)
|
279
279
|
|
280
280
|
|
281
|
-
|
281
|
+
void lsapi_perror(const char * pMessage, int err_no)
|
282
|
+
{
|
283
|
+
lsapi_log("%s, errno: %d (%s)\n", pMessage, err_no, strerror(err_no));
|
284
|
+
}
|
285
|
+
|
286
|
+
|
287
|
+
static int lsapi_parent_dead()
|
282
288
|
{
|
283
289
|
// Return non-zero if the parent is dead. 0 if still alive.
|
284
290
|
if (!s_ppid) {
|
@@ -874,7 +880,8 @@ int LSAPI_is_suEXEC_Daemon(void)
|
|
874
880
|
static int LSAPI_perror_r( LSAPI_Request * pReq, const char * pErr1, const char *pErr2 )
|
875
881
|
{
|
876
882
|
char achError[4096];
|
877
|
-
int n = snprintf(achError, sizeof(achError), "[%d] %s:%s: %s\n",
|
883
|
+
int n = snprintf(achError, sizeof(achError), "[UID:%d][%d] %s:%s: %s\n",
|
884
|
+
getuid(), getpid(),
|
878
885
|
pErr1, (pErr2)?pErr2:"", strerror(errno));
|
879
886
|
if (n > (int)sizeof(achError))
|
880
887
|
n = sizeof(achError);
|
@@ -2605,7 +2612,8 @@ int LSAPI_ParseSockAddr( const char * pBind, struct sockaddr * pAddr )
|
|
2605
2612
|
while( isspace( *pBind ) )
|
2606
2613
|
++pBind;
|
2607
2614
|
|
2608
|
-
strncpy(
|
2615
|
+
strncpy(achAddr, pBind, 255);
|
2616
|
+
achAddr[255] = 0;
|
2609
2617
|
|
2610
2618
|
switch( *p )
|
2611
2619
|
{
|
@@ -2953,9 +2961,9 @@ static void dump_debug_info( lsapi_child_status * pStatus, long tmCur )
|
|
2953
2961
|
return;
|
2954
2962
|
}
|
2955
2963
|
|
2956
|
-
lsapi_log("Possible runaway process, PPID: %d, PID: %d, "
|
2964
|
+
lsapi_log("Possible runaway process, UID: %d, PPID: %d, PID: %d, "
|
2957
2965
|
"reqCount: %d, process time: %ld, checkpoint time: %ld, start "
|
2958
|
-
"time: %ld\n",
|
2966
|
+
"time: %ld\n", getuid(), getppid(), pStatus->m_pid,
|
2959
2967
|
pStatus->m_iReqCounter, tmCur - pStatus->m_tmReqBegin,
|
2960
2968
|
tmCur - pStatus->m_tmLastCheckPoint, tmCur - pStatus->m_tmStart );
|
2961
2969
|
|
@@ -2983,7 +2991,7 @@ static void lsapi_check_child_status( long tmCur )
|
|
2983
2991
|
while( pStatus < pEnd )
|
2984
2992
|
{
|
2985
2993
|
tobekilled = 0;
|
2986
|
-
if ( pStatus->m_pid != 0 )
|
2994
|
+
if ( pStatus->m_pid != 0 && pStatus->m_pid != -1)
|
2987
2995
|
{
|
2988
2996
|
++count;
|
2989
2997
|
if ( !pStatus->m_inProcess )
|
@@ -3177,8 +3185,6 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer,
|
|
3177
3185
|
if (pServer->m_iCurChildren > 0
|
3178
3186
|
&& accepting > 0)
|
3179
3187
|
{
|
3180
|
-
lsapi_log("children: %d, accepting: %d\n",
|
3181
|
-
pServer->m_iCurChildren, accepting);
|
3182
3188
|
usleep( 400);
|
3183
3189
|
while(accepting-- > 0)
|
3184
3190
|
sched_yield();
|
@@ -3270,7 +3276,9 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer,
|
|
3270
3276
|
}
|
3271
3277
|
else if ( pid == -1 )
|
3272
3278
|
{
|
3273
|
-
|
3279
|
+
lsapi_perror("fork() failed, please increase process limit", errno);
|
3280
|
+
if (child_status)
|
3281
|
+
child_status->m_pid = 0;
|
3274
3282
|
}
|
3275
3283
|
else
|
3276
3284
|
{
|
@@ -3293,7 +3301,7 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer,
|
|
3293
3301
|
{
|
3294
3302
|
if (( errno == EINTR )||( errno == EAGAIN))
|
3295
3303
|
continue;
|
3296
|
-
|
3304
|
+
lsapi_perror("accept() failed", errno);
|
3297
3305
|
return -1;
|
3298
3306
|
}
|
3299
3307
|
}
|
@@ -3450,8 +3458,6 @@ int LSAPI_Accept_Before_Fork(LSAPI_Request * pReq)
|
|
3450
3458
|
if (pServer->m_iCurChildren > 0
|
3451
3459
|
&& accepting > 0)
|
3452
3460
|
{
|
3453
|
-
lsapi_log("children: %d, accepting: %d\n",
|
3454
|
-
pServer->m_iCurChildren, accepting);
|
3455
3461
|
usleep( 400);
|
3456
3462
|
while(accepting-- > 0)
|
3457
3463
|
sched_yield();
|
@@ -3495,7 +3501,7 @@ int LSAPI_Accept_Before_Fork(LSAPI_Request * pReq)
|
|
3495
3501
|
{
|
3496
3502
|
if ((errno == EINTR) || (errno == EAGAIN))
|
3497
3503
|
continue;
|
3498
|
-
|
3504
|
+
lsapi_perror("accept() failed", errno);
|
3499
3505
|
ret = -1;
|
3500
3506
|
break;
|
3501
3507
|
}
|
@@ -3511,13 +3517,6 @@ int LSAPI_Accept_Before_Fork(LSAPI_Request * pReq)
|
|
3511
3517
|
}
|
3512
3518
|
|
3513
3519
|
|
3514
|
-
void lsapi_perror( const char * pMessage, int err_no )
|
3515
|
-
{
|
3516
|
-
lsapi_log("%s, errno: %d (%s)\n", pMessage, err_no,
|
3517
|
-
strerror( err_no ) );
|
3518
|
-
}
|
3519
|
-
|
3520
|
-
|
3521
3520
|
int LSAPI_Prefork_Accept_r( LSAPI_Request * pReq )
|
3522
3521
|
{
|
3523
3522
|
int fd;
|
data/ext/lsapi/lsruby.c
CHANGED
@@ -808,6 +808,7 @@ void Init_lsapi()
|
|
808
808
|
{
|
809
809
|
VALUE orig_verbose;
|
810
810
|
char * p;
|
811
|
+
int prefork = 0;
|
811
812
|
LSAPI_Init();
|
812
813
|
initBodyBuf();
|
813
814
|
|
@@ -822,15 +823,18 @@ void Init_lsapi()
|
|
822
823
|
|
823
824
|
s_pid = getpid();
|
824
825
|
|
825
|
-
p = getenv( "
|
826
|
+
p = getenv( "RACK_ROOT" );
|
826
827
|
if ( p )
|
827
828
|
{
|
828
829
|
if ( chdir( p ) == -1 )
|
829
830
|
perror( "chdir()" );
|
830
831
|
}
|
831
|
-
if ( p || getenv( "
|
832
|
+
if ( p || getenv( "RACK_ENV" ) )
|
832
833
|
s_fn_add_env = add_env_rails;
|
833
834
|
|
835
|
+
p = getenv("LSAPI_CHILDREN");
|
836
|
+
if (p && atoi(p) > 1)
|
837
|
+
prefork = 1;
|
834
838
|
|
835
839
|
orig_stdin = rb_stdin;
|
836
840
|
orig_stdout = rb_stdout;
|
@@ -851,9 +855,12 @@ void Init_lsapi()
|
|
851
855
|
|
852
856
|
cLSAPI = rb_define_class("LSAPI", rb_cObject);
|
853
857
|
rb_define_singleton_method(cLSAPI, "accept", lsapi_s_accept, 0);
|
854
|
-
|
855
|
-
|
856
|
-
|
858
|
+
if (prefork)
|
859
|
+
{
|
860
|
+
rb_define_singleton_method(cLSAPI, "accept_new_connection", lsapi_s_accept_new_conn, 0);
|
861
|
+
rb_define_singleton_method(cLSAPI, "postfork_child", lsapi_s_postfork_child, 0);
|
862
|
+
rb_define_singleton_method(cLSAPI, "postfork_parent", lsapi_s_postfork_parent, 0);
|
863
|
+
}
|
857
864
|
|
858
865
|
rb_define_method(cLSAPI, "process", lsapi_process, 0 );
|
859
866
|
/* rb_define_method(cLSAPI, "initialize", lsapi_initialize, 0); */
|
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 = "5.
|
4
|
-
s.date = %q{2020-
|
3
|
+
s.version = "5.1"
|
4
|
+
s.date = %q{2020-09-01}
|
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: '5.
|
4
|
+
version: '5.1'
|
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: 2020-
|
11
|
+
date: 2020-09-01 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
|