ruby-lsapi 2.6 → 2.7

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -71,39 +71,55 @@ With Rails easy configuration, LSAPI_CHILDREN is set to the value of
71
71
  "Max Connections" by web server, no need to set it explicitly.
72
72
 
73
73
  Usually, there is no need to set value of LSAPI_CHILDREN over 100 in most
74
- server environment.
74
+ server environment.
75
75
 
76
76
 
77
- * LSAPI_EXTRA_CHILDREN (default: 0)
77
+ * LSAPI_AVOID_FORK (default: 0)
78
+
79
+ LSAPI_AVOID_FORK specifies the policy of the internal process manager in
80
+ "Self Managed Mode". When set to 0, the internal process manager will stop
81
+ and start children process on demand to save system resource. This is
82
+ preferred in a shared hosting environment. When set to 1, the internal
83
+ process manager will try to avoid freqently stopping and starting children
84
+ process. This might be preferred in a dedicate hosting environment.
85
+
86
+
87
+ * LSAPI_EXTRA_CHILDREN (default: 1/3 of LSAPI_CHILDREN or 0)
78
88
 
79
89
  LSAPI_EXTRA_CHILDREN controls the maximum number of extra children processes
80
90
  can be started when some or all existing children processes are in
81
91
  malfunctioning state. Total number of children processes will be reduced to
82
- LSAPI_CHILDREN level as soon as service is back to normal.
92
+ LSAPI_CHILDREN level as soon as service is back to normal.
93
+ When LSAPI_AVOID_FORK is set to 0, the default value is 1/3 of
94
+ LSAPI_CHIDLREN, When LSAPI_AVOID_FORK is set to 1, the default value is 0.
83
95
 
84
96
 
85
- * LSAPI_MAX_REQS (default value: 10000)
97
+ * LSAPI_MAX_REQS (default value: 10000)
86
98
 
87
99
  LSAPI_MAX_REQS specifies the maximum number of requests each child
88
100
  process will handle before it exits automatically. This parameter can
89
101
  help reducing memory usage when there are memory leaks in the application.
90
102
 
91
103
 
92
- * LSAPI_MAX_IDLE (default value: 300 seconds)
104
+ * LSAPI_MAX_IDLE (default value: 300 seconds)
93
105
 
94
106
  In Self Managed Mode, LSAPI_MAX_IDLE controls how long a idle child
95
107
  process will wait for a new request before exit. This option help
96
108
  releasing system resources taken by idle processes.
97
109
 
98
110
 
99
- * LSAPI_MAX_IDLE_CHILDREN (default value: LSAPI_CHILDREN)
111
+ * LSAPI_MAX_IDLE_CHILDREN
112
+ (default value: 1/3 of LSAPI_CHILDREN or LSAPI_CHILDREN)
100
113
 
101
114
  In Self Managed Mode, LSAI_MAX_IDLE_CHILDREN controls how many idle
102
115
  children processes are allowed. Excessive idle children processes
103
116
  will be killed by the parent process.
117
+ When LSAPI_AVOID_FORK is set to 0, the default value is 1/3 of
118
+ LSAPI_CHIDLREN, When LSAPI_AVOID_FORK is set to 1, the default value
119
+ is LSAPI_CHILDREN.
104
120
 
105
121
 
106
- * LSAPI_MAX_PROCESS_TIME (default value: 300 seconds)
122
+ * LSAPI_MAX_PROCESS_TIME (default value: 300 seconds)
107
123
 
108
124
  In Self Managed Mode, LSAPI_MAX_PROCESS_TIME controls the maximum
109
125
  processing time allowed when processing a request. If a child process
@@ -112,7 +128,7 @@ will be killed by the parent process. This option can help getting rid
112
128
  of dead or runaway child process.
113
129
 
114
130
 
115
- * LSAPI_PGRP_MAX_IDLE (default value: FOREVER )
131
+ * LSAPI_PGRP_MAX_IDLE (default value: FOREVER )
116
132
 
117
133
  In Self Managed Mode, LSAPI_PGRP_MAX_IDLE controls how long the parent
118
134
  process will wait before exiting when there is no child process.
data/ext/lsapi/lsapilib.c CHANGED
@@ -864,8 +864,11 @@ int LSAPI_ReadReqBody_r( LSAPI_Request * pReq, char * pBuf, int bufLen )
864
864
  bufLen -= len;
865
865
  }
866
866
  else if ( len <= 0 )
867
+ {
867
868
  if ( !total)
868
869
  return -1;
870
+ break;
871
+ }
869
872
  }
870
873
  pReq->m_reqBodyRead += total;
871
874
  return total;
@@ -1493,6 +1496,7 @@ typedef struct _lsapi_prefork_server
1493
1496
  int m_iServerMaxIdle;
1494
1497
  int m_iChildrenMaxIdleTime;
1495
1498
  int m_iMaxReqProcessTime;
1499
+ int m_iAvoidFork;
1496
1500
 
1497
1501
  lsapi_child_status * m_pChildrenStatus;
1498
1502
 
@@ -1500,7 +1504,7 @@ typedef struct _lsapi_prefork_server
1500
1504
 
1501
1505
  static lsapi_prefork_server * g_prefork_server = NULL;
1502
1506
 
1503
- int LSAPI_Init_Prefork_Server( int max_children, fn_select_t fp )
1507
+ int LSAPI_Init_Prefork_Server( int max_children, fn_select_t fp, int avoidFork )
1504
1508
  {
1505
1509
  if ( g_prefork_server )
1506
1510
  return 0;
@@ -1508,7 +1512,8 @@ int LSAPI_Init_Prefork_Server( int max_children, fn_select_t fp )
1508
1512
  return -1;
1509
1513
  if ( max_children >= 10000)
1510
1514
  max_children = 10000;
1511
-
1515
+
1516
+
1512
1517
  g_prefork_server = (lsapi_prefork_server *)malloc( sizeof( lsapi_prefork_server ) );
1513
1518
  if ( !g_prefork_server )
1514
1519
  return -1;
@@ -1518,9 +1523,11 @@ int LSAPI_Init_Prefork_Server( int max_children, fn_select_t fp )
1518
1523
  g_fnSelect = fp;
1519
1524
 
1520
1525
  s_ppid = getppid();
1526
+ g_prefork_server->m_iAvoidFork = avoidFork;
1521
1527
  g_prefork_server->m_iMaxChildren = max_children;
1522
- g_prefork_server->m_iExtraChildren = 0 ;
1523
- g_prefork_server->m_iMaxIdleChildren = max_children + 1;
1528
+
1529
+ g_prefork_server->m_iExtraChildren = ( avoidFork ) ? 0 : max_children / 3 ;
1530
+ g_prefork_server->m_iMaxIdleChildren = ( avoidFork ) ? (max_children + 1) : max_children / 3;
1524
1531
  g_prefork_server->m_iChildrenMaxIdleTime = 300;
1525
1532
  g_prefork_server->m_iMaxReqProcessTime = 300;
1526
1533
  return 0;
@@ -2012,6 +2019,7 @@ void LSAPI_Init_Env_Parameters( fn_select_t fp )
2012
2019
  {
2013
2020
  const char *p;
2014
2021
  int n;
2022
+ int avoidFork = 0;
2015
2023
  p = getenv( "PHP_LSAPI_MAX_REQUESTS" );
2016
2024
  if ( !p )
2017
2025
  p = getenv( "LSAPI_MAX_REQS" );
@@ -2022,6 +2030,12 @@ void LSAPI_Init_Env_Parameters( fn_select_t fp )
2022
2030
  LSAPI_Set_Max_Reqs( n );
2023
2031
  }
2024
2032
 
2033
+ p = getenv( "LSAPI_AVOID_FORK" );
2034
+ if ( p )
2035
+ {
2036
+ avoidFork = atoi( p );
2037
+ }
2038
+
2025
2039
  p = getenv( "LSAPI_MAX_IDLE" );
2026
2040
  if ( p )
2027
2041
  {
@@ -2039,7 +2053,7 @@ void LSAPI_Init_Env_Parameters( fn_select_t fp )
2039
2053
  n = atoi( p );
2040
2054
  if ( n > 1 )
2041
2055
  {
2042
- LSAPI_Init_Prefork_Server( n, fp );
2056
+ LSAPI_Init_Prefork_Server( n, fp, avoidFork );
2043
2057
  LSAPI_Set_Server_fd( g_req.m_fdListen );
2044
2058
  }
2045
2059
 
data/ext/lsapi/lsapilib.h CHANGED
@@ -304,7 +304,7 @@ int LSAPI_CreateListenSock( const char * pBind, int backlog );
304
304
 
305
305
  typedef int (*fn_select_t)( int, fd_set *, fd_set *, fd_set *, struct timeval * );
306
306
 
307
- int LSAPI_Init_Prefork_Server( int max_children, fn_select_t fp );
307
+ int LSAPI_Init_Prefork_Server( int max_children, fn_select_t fp, int avoidFork );
308
308
 
309
309
  void LSAPI_Set_Server_fd( int fd );
310
310
 
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.6"
7
- date: 2007-08-04 00:00:00 -04:00
6
+ version: "2.7"
7
+ date: 2007-08-19 00:00:00 -04:00
8
8
  summary: A ruby extension for fast communication with LiteSpeed Web Server.
9
9
  require_paths:
10
10
  - lib