ruby-lsapi 3.1 → 3.2
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/lsapilib.c +47 -16
- metadata +2 -2
data/ext/lsapi/lsapilib.c
CHANGED
@@ -167,6 +167,26 @@ static inline void lsapi_buildPacketHeader( struct lsapi_packet_header * pHeader
|
|
167
167
|
pHeader->m_packetLen.m_iLen = len;
|
168
168
|
}
|
169
169
|
|
170
|
+
static int lsapi_set_nblock( int fd, int nonblock )
|
171
|
+
{
|
172
|
+
int val = fcntl( fd, F_GETFL, 0 );
|
173
|
+
if ( nonblock )
|
174
|
+
{
|
175
|
+
if (!( val & O_NONBLOCK ))
|
176
|
+
{
|
177
|
+
return fcntl( fd, F_SETFL, val | O_NONBLOCK );
|
178
|
+
}
|
179
|
+
}
|
180
|
+
else
|
181
|
+
{
|
182
|
+
if ( val & O_NONBLOCK )
|
183
|
+
{
|
184
|
+
return fcntl( fd, F_SETFL, val &(~O_NONBLOCK) );
|
185
|
+
}
|
186
|
+
}
|
187
|
+
return 0;
|
188
|
+
}
|
189
|
+
|
170
190
|
static int lsapi_close( int fd )
|
171
191
|
{
|
172
192
|
int ret;
|
@@ -333,7 +353,7 @@ static int allocateEnvList( struct LSAPI_key_value_pair ** pEnvList,
|
|
333
353
|
int *curSize, int newSize )
|
334
354
|
{
|
335
355
|
struct LSAPI_key_value_pair * pBuf;
|
336
|
-
|
356
|
+
if ( *curSize >= newSize )
|
337
357
|
return 0;
|
338
358
|
if ( newSize > 8192 )
|
339
359
|
return -1;
|
@@ -365,7 +385,7 @@ static int parseEnv( struct LSAPI_key_value_pair * pEnvList, int count,
|
|
365
385
|
char **pBegin, char * pEnd )
|
366
386
|
{
|
367
387
|
struct LSAPI_key_value_pair * pEnvEnd;
|
368
|
-
|
388
|
+
int keyLen = 0, valLen = 0;
|
369
389
|
if ( count > 8192 )
|
370
390
|
return -1;
|
371
391
|
pEnvEnd = pEnvList + count;
|
@@ -523,8 +543,8 @@ static inline int notify_req_received( LSAPI_Request * pReq )
|
|
523
543
|
|
524
544
|
static int readReq( LSAPI_Request * pReq )
|
525
545
|
{
|
526
|
-
|
527
|
-
|
546
|
+
int len;
|
547
|
+
int packetLen;
|
528
548
|
if ( !pReq )
|
529
549
|
return -1;
|
530
550
|
if ( pReq->m_reqBufSize < 8192 )
|
@@ -620,6 +640,7 @@ int LSAPI_InitRequest( LSAPI_Request * pReq, int fd )
|
|
620
640
|
{
|
621
641
|
pReq->m_fdListen = fd;
|
622
642
|
pReq->m_fd = -1;
|
643
|
+
lsapi_set_nblock( fd, 1 );
|
623
644
|
}
|
624
645
|
return 0;
|
625
646
|
}
|
@@ -662,10 +683,14 @@ int LSAPI_Accept_r( LSAPI_Request * pReq )
|
|
662
683
|
else
|
663
684
|
return -1;
|
664
685
|
}
|
665
|
-
else
|
666
|
-
{
|
667
|
-
|
668
|
-
|
686
|
+
else
|
687
|
+
{
|
688
|
+
lsapi_set_nblock( pReq->m_fd , 0 );
|
689
|
+
if (((struct sockaddr *)&achPeer)->sa_family == AF_INET )
|
690
|
+
{
|
691
|
+
setsockopt(pReq->m_fd, IPPROTO_TCP, TCP_NODELAY,
|
692
|
+
(char *)&nodelay, sizeof(nodelay));
|
693
|
+
}
|
669
694
|
}
|
670
695
|
}
|
671
696
|
else
|
@@ -746,10 +771,10 @@ char * LSAPI_GetHeader_r( LSAPI_Request * pReq, int headerIndex )
|
|
746
771
|
off = pReq->m_pHeaderIndex->m_headerOff[ headerIndex ];
|
747
772
|
if ( !off )
|
748
773
|
return NULL;
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
774
|
+
if ( *(pReq->m_pHttpHeader + off +
|
775
|
+
pReq->m_pHeaderIndex->m_headerLen[ headerIndex ]) )
|
776
|
+
*( pReq->m_pHttpHeader + off +
|
777
|
+
pReq->m_pHeaderIndex->m_headerLen[ headerIndex ]) = 0;
|
753
778
|
return pReq->m_pHttpHeader + off;
|
754
779
|
}
|
755
780
|
|
@@ -1681,7 +1706,7 @@ static int lsapi_init_children_status()
|
|
1681
1706
|
return -1;
|
1682
1707
|
}
|
1683
1708
|
memset( pBuf, 0, size );
|
1684
|
-
g_prefork_server->m_pChildrenStatus = (lsapi_child_status *)pBuf;
|
1709
|
+
g_prefork_server->m_pChildrenStatus = (lsapi_child_status *)pBuf;
|
1685
1710
|
return 0;
|
1686
1711
|
}
|
1687
1712
|
|
@@ -1762,6 +1787,7 @@ static int lsapi_all_children_must_die()
|
|
1762
1787
|
while( g_prefork_server->m_iCurChildren && (sec < maxWait) )
|
1763
1788
|
{
|
1764
1789
|
lsapi_check_child_status(time(NULL));
|
1790
|
+
sleep( 1 );
|
1765
1791
|
sec++;
|
1766
1792
|
}
|
1767
1793
|
if ( g_prefork_server->m_iCurChildren != 0 )
|
@@ -1817,8 +1843,7 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer, LSAPI_Re
|
|
1817
1843
|
if (curTime != lastTime )
|
1818
1844
|
{
|
1819
1845
|
lastTime = curTime;
|
1820
|
-
if (s_ppid &&
|
1821
|
-
(kill(s_ppid, 0) == -1)&&(errno == ESRCH))
|
1846
|
+
if (s_ppid && (getppid() != s_ppid ))
|
1822
1847
|
break;
|
1823
1848
|
lsapi_check_child_status(curTime );
|
1824
1849
|
if (pServer->m_iServerMaxIdle)
|
@@ -1879,6 +1904,7 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer, LSAPI_Re
|
|
1879
1904
|
s_req_processed = 0;
|
1880
1905
|
s_pChildStatus = child_status;
|
1881
1906
|
child_status->m_iKillSent = 0;
|
1907
|
+
lsapi_set_nblock( pReq->m_fd, 0 );
|
1882
1908
|
|
1883
1909
|
/* don't catch our signals */
|
1884
1910
|
sigaction( SIGCHLD, &old_child, 0 );
|
@@ -1977,7 +2003,7 @@ int LSAPI_Prefork_Accept_r( LSAPI_Request * pReq )
|
|
1977
2003
|
++wait_secs;
|
1978
2004
|
if (( s_max_idle_secs > 0 )&&(wait_secs >= s_max_idle_secs ))
|
1979
2005
|
return -1;
|
1980
|
-
if ( s_ppid &&(
|
2006
|
+
if ( s_ppid &&( getppid() != s_ppid))
|
1981
2007
|
return -1;
|
1982
2008
|
}
|
1983
2009
|
else if ( ret == -1 )
|
@@ -1997,9 +2023,14 @@ int LSAPI_Prefork_Accept_r( LSAPI_Request * pReq )
|
|
1997
2023
|
if ( pReq->m_fd != -1 )
|
1998
2024
|
{
|
1999
2025
|
fd = pReq->m_fd;
|
2026
|
+
lsapi_set_nblock( fd, 0 );
|
2000
2027
|
}
|
2001
2028
|
else
|
2029
|
+
{
|
2030
|
+
if (( errno == EINTR )||( errno == EAGAIN))
|
2031
|
+
continue;
|
2002
2032
|
return -1;
|
2033
|
+
}
|
2003
2034
|
}
|
2004
2035
|
else
|
2005
2036
|
break;
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ruby-lsapi
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: "3.
|
7
|
-
date: 2008-
|
6
|
+
version: "3.2"
|
7
|
+
date: 2008-04-11 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
|