ruby-lsapi 5.8 → 5.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/lsapilib.h CHANGED
@@ -304,7 +304,11 @@ static inline int LSAPI_ReqBodyGetChar(void)
304
304
  { return LSAPI_ReqBodyGetChar_r( &g_req ); }
305
305
 
306
306
  static inline int LSAPI_ReqBodyGetLine( char * pBuf, int len, int *getLF )
307
- { return LSAPI_ReqBodyGetLine_r( &g_req, pBuf, len, getLF ); }
307
+ {
308
+ if (len <= 0)
309
+ return -1;
310
+ return LSAPI_ReqBodyGetLine_r( &g_req, pBuf, (size_t)len, getLF );
311
+ }
308
312
 
309
313
 
310
314
 
@@ -312,7 +316,11 @@ static inline int LSAPI_FinalizeRespHeaders(void)
312
316
  { return LSAPI_FinalizeRespHeaders_r( &g_req ); }
313
317
 
314
318
  static inline ssize_t LSAPI_Write( const char * pBuf, ssize_t len )
315
- { return LSAPI_Write_r( &g_req, pBuf, len ); }
319
+ {
320
+ if (len < 0)
321
+ return -1;
322
+ return LSAPI_Write_r( &g_req, pBuf, (size_t)len );
323
+ }
316
324
 
317
325
  static inline ssize_t LSAPI_sendfile( int fdIn, off_t* off, size_t size )
318
326
  {
@@ -320,7 +328,11 @@ static inline ssize_t LSAPI_sendfile( int fdIn, off_t* off, size_t size )
320
328
  }
321
329
 
322
330
  static inline ssize_t LSAPI_Write_Stderr( const char * pBuf, ssize_t len )
323
- { return LSAPI_Write_Stderr_r( &g_req, pBuf, len ); }
331
+ {
332
+ if (len < 0)
333
+ return -1;
334
+ return LSAPI_Write_Stderr_r( &g_req, pBuf, (size_t)len );
335
+ }
324
336
 
325
337
  static inline int LSAPI_Flush(void)
326
338
  { return LSAPI_Flush_r( &g_req ); }
@@ -376,6 +388,14 @@ int LSAPI_Set_Restored_Parent_Pid(int pid);
376
388
  typedef void (*LSAPI_On_Timer_pf)(int *forked_child_pid);
377
389
  void LSAPI_Register_Pgrp_Timer_Callback(LSAPI_On_Timer_pf);
378
390
 
391
+ /* Called around the fork() of each worker by the prefork server
392
+ * (LSAPI_Prefork_Accept_r): before in the parent, then after_parent in the
393
+ * parent (also when fork() fails) or after_child in the new worker. */
394
+ typedef void (*LSAPI_Fork_Hook_pf)(void);
395
+ void LSAPI_Set_Fork_Hooks(LSAPI_Fork_Hook_pf before,
396
+ LSAPI_Fork_Hook_pf after_parent,
397
+ LSAPI_Fork_Hook_pf after_child);
398
+
379
399
  int LSAPI_Inc_Req_Processed(int cnt);
380
400
 
381
401
  int LSAPI_Accept_Before_Fork(LSAPI_Request * pReq);
@@ -384,6 +404,8 @@ int LSAPI_Postfork_Child(LSAPI_Request * pReq);
384
404
 
385
405
  int LSAPI_Postfork_Parent(LSAPI_Request * pReq);
386
406
 
407
+ int LSAPI_Postfork_Failed(LSAPI_Request * pReq);
408
+
387
409
  #define LSAPI_LOG_LEVEL_BITS 0xff
388
410
  #define LSAPI_LOG_FLAG_NONE 0
389
411
  #define LSAPI_LOG_FLAG_DEBUG 1
@@ -420,4 +442,3 @@ void LSAPI_Log(int flag, const char * fmt, ...)
420
442
 
421
443
 
422
444
 
423
-