php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
lsapilib.c File Reference
#include <ctype.h>
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <sys/stat.h>
#include <sched.h>
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/uio.h>
#include <sys/wait.h>
#include <grp.h>
#include <pwd.h>
#include <time.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/un.h>
#include <php_config.h>
#include "lsapilib.h"
#include <inttypes.h>
#include <Zend/zend_portability.h>

Go to the source code of this file.

Data Structures

struct  lsapi_MD5Context
 
struct  lsapi_child_status
 
struct  _headerInfo
 
struct  _lsapi_prefork_server
 

Macros

#define uint32   uint32_t
 
#define LSAPI_ST_REQ_HEADER   1
 
#define LSAPI_ST_REQ_BODY   2
 
#define LSAPI_ST_RESP_HEADER   4
 
#define LSAPI_ST_RESP_BODY   8
 
#define LSAPI_ST_BACKGROUND   16
 
#define LSAPI_RESP_BUF_SIZE   8192
 
#define LSAPI_INIT_RESP_HEADER_LEN   4096
 
#define lsapi_dbg(...)
 
#define lsapi_log(...)
 
#define F1(x, y, z)
 
#define F2(x, y, z)
 
#define F3(x, y, z)
 
#define F4(x, y, z)
 
#define MD5STEP(f, w, x, y, z, data, s)
 

Typedefs

typedef struct lsapi_MD5Context lsapi_MD5_CTX
 
typedef struct lsapi_child_status lsapi_child_status
 
typedef void(* sighandler_t) (int)
 
typedef struct _lsapi_prefork_server lsapi_prefork_server
 

Enumerations

enum  { LSAPI_STATE_IDLE , LSAPI_STATE_CONNECTED , LSAPI_STATE_ACCEPTING }
 

Functions

void lsapi_MD5Init (struct lsapi_MD5Context *context)
 
void lsapi_MD5Update (struct lsapi_MD5Context *context, unsigned char const *buf, unsigned len)
 
void lsapi_MD5Final (unsigned char digest[16], struct lsapi_MD5Context *context)
 
void Flush_RespBuf_r (LSAPI_Request *pReq)
 
void LSAPI_Log (int flag, const char *fmt,...)
 
void lsapi_perror (const char *pMessage, int err_no)
 
int LSAPI_is_suEXEC_Daemon (void)
 
int LSAPI_Init (void)
 
void LSAPI_Stop (void)
 
int LSAPI_IsRunning (void)
 
void LSAPI_Register_Pgrp_Timer_Callback (LSAPI_On_Timer_pf cb)
 
int LSAPI_InitRequest (LSAPI_Request *pReq, int fd)
 
int LSAPI_Is_Listen (void)
 
int LSAPI_Is_Listen_r (LSAPI_Request *pReq)
 
int LSAPI_Accept_r (LSAPI_Request *pReq)
 
int LSAPI_Finish_r (LSAPI_Request *pReq)
 
int LSAPI_End_Response_r (LSAPI_Request *pReq)
 
void LSAPI_Reset_r (LSAPI_Request *pReq)
 
int LSAPI_Release_r (LSAPI_Request *pReq)
 
char * LSAPI_GetHeader_r (LSAPI_Request *pReq, int headerIndex)
 
int LSAPI_ReqBodyGetChar_r (LSAPI_Request *pReq)
 
int LSAPI_ReqBodyGetLine_r (LSAPI_Request *pReq, char *pBuf, size_t bufLen, int *getLF)
 
ssize_t LSAPI_ReadReqBody_r (LSAPI_Request *pReq, char *pBuf, size_t bufLen)
 
ssize_t LSAPI_Write_r (LSAPI_Request *pReq, const char *pBuf, size_t len)
 
ssize_t LSAPI_sendfile_r (LSAPI_Request *pReq, int fdIn, off_t *off, size_t size)
 
int LSAPI_Flush_r (LSAPI_Request *pReq)
 
ssize_t LSAPI_Write_Stderr_r (LSAPI_Request *pReq, const char *pBuf, size_t len)
 
char * LSAPI_GetEnv_r (LSAPI_Request *pReq, const char *name)
 
int compareValueLocation (const void *v1, const void *v2)
 
int LSAPI_ForeachOrgHeader_r (LSAPI_Request *pReq, LSAPI_CB_EnvHandler fn, void *arg)
 
int LSAPI_ForeachHeader_r (LSAPI_Request *pReq, LSAPI_CB_EnvHandler fn, void *arg)
 
int LSAPI_ForeachEnv_r (LSAPI_Request *pReq, LSAPI_CB_EnvHandler fn, void *arg)
 
int LSAPI_ForeachSpecialEnv_r (LSAPI_Request *pReq, LSAPI_CB_EnvHandler fn, void *arg)
 
int LSAPI_FinalizeRespHeaders_r (LSAPI_Request *pReq)
 
int LSAPI_AppendRespHeader2_r (LSAPI_Request *pReq, const char *pHeaderName, const char *pHeaderValue)
 
int LSAPI_AppendRespHeader_r (LSAPI_Request *pReq, const char *pBuf, int len)
 
int LSAPI_CreateListenSock2 (const struct sockaddr *pServerAddr, int backlog)
 
int LSAPI_ParseSockAddr (const char *pBind, struct sockaddr *pAddr)
 
int LSAPI_CreateListenSock (const char *pBind, int backlog)
 
int LSAPI_Init_Prefork_Server (int max_children, fn_select_t fp, int avoidFork)
 
void LSAPI_Set_Server_fd (int fd)
 
void LSAPI_reset_server_state (void)
 
void set_skip_write (void)
 
int is_enough_free_mem (void)
 
int LSAPI_Postfork_Child (LSAPI_Request *pReq)
 
int LSAPI_Postfork_Parent (LSAPI_Request *pReq)
 
int LSAPI_Accept_Before_Fork (LSAPI_Request *pReq)
 
int LSAPI_Prefork_Accept_r (LSAPI_Request *pReq)
 
void LSAPI_Set_Max_Reqs (int reqs)
 
void LSAPI_Set_Max_Idle (int secs)
 
void LSAPI_Set_Max_Children (int maxChildren)
 
void LSAPI_Set_Extra_Children (int extraChildren)
 
void LSAPI_Set_Max_Process_Time (int secs)
 
void LSAPI_Set_Max_Idle_Children (int maxIdleChld)
 
void LSAPI_Set_Server_Max_Idle_Secs (int serverMaxIdle)
 
void LSAPI_Set_Slow_Req_Msecs (int msecs)
 
int LSAPI_Get_Slow_Req_Msecs (void)
 
void LSAPI_No_Check_ppid (void)
 
int LSAPI_Get_ppid (void)
 
int LSAPI_Init_Env_Parameters (fn_select_t fp)
 
int LSAPI_ErrResponse_r (LSAPI_Request *pReq, int code, const char **pRespHeaders, const char *pBody, int bodyLen)
 
int LSAPI_Set_Restored_Parent_Pid (int pid)
 
int LSAPI_Inc_Req_Processed (int cnt)
 

Variables

LSAPI_Request g_req
 
char ** environ
 

Macro Definition Documentation

◆ F1

#define F1 ( x,
y,
z )
Value:
(z ^ (x & (y ^ z)))

Definition at line 4254 of file lsapilib.c.

◆ F2

#define F2 ( x,
y,
z )
Value:
F1(z, x, y)
#define F1(name, info)

Definition at line 4255 of file lsapilib.c.

◆ F3

#define F3 ( x,
y,
z )
Value:
(x ^ y ^ z)

Definition at line 4256 of file lsapilib.c.

◆ F4

#define F4 ( x,
y,
z )
Value:
(y ^ (x | ~z))

Definition at line 4257 of file lsapilib.c.

◆ lsapi_dbg

#define lsapi_dbg ( ...)

Definition at line 292 of file lsapilib.c.

◆ LSAPI_INIT_RESP_HEADER_LEN

#define LSAPI_INIT_RESP_HEADER_LEN   4096

Definition at line 121 of file lsapilib.c.

◆ lsapi_log

#define lsapi_log ( ...)
Value:
void LSAPI_Log(int flag, const char *fmt,...)
Definition lsapilib.c:242
#define LSAPI_LOG_TIMESTAMP_FULL
Definition lsapilib.h:414
#define LSAPI_LOG_PID
Definition lsapilib.h:418

Definition at line 296 of file lsapilib.c.

◆ LSAPI_RESP_BUF_SIZE

#define LSAPI_RESP_BUF_SIZE   8192

Definition at line 120 of file lsapilib.c.

◆ LSAPI_ST_BACKGROUND

#define LSAPI_ST_BACKGROUND   16

Definition at line 118 of file lsapilib.c.

◆ LSAPI_ST_REQ_BODY

#define LSAPI_ST_REQ_BODY   2

Definition at line 115 of file lsapilib.c.

◆ LSAPI_ST_REQ_HEADER

#define LSAPI_ST_REQ_HEADER   1

Definition at line 114 of file lsapilib.c.

◆ LSAPI_ST_RESP_BODY

#define LSAPI_ST_RESP_BODY   8

Definition at line 117 of file lsapilib.c.

◆ LSAPI_ST_RESP_HEADER

#define LSAPI_ST_RESP_HEADER   4

Definition at line 116 of file lsapilib.c.

◆ MD5STEP

#define MD5STEP ( f,
w,
x,
y,
z,
data,
s )
Value:
( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x )
char s[4]
Definition cdf.c:77
zend_constant * data

Definition at line 4260 of file lsapilib.c.

◆ uint32

#define uint32   uint32_t

Definition at line 92 of file lsapilib.c.

Typedef Documentation

◆ lsapi_child_status

typedef struct lsapi_child_status lsapi_child_status

◆ lsapi_MD5_CTX

Definition at line 111 of file lsapilib.c.

◆ lsapi_prefork_server

◆ sighandler_t

typedef void(* sighandler_t) (int)

Definition at line 336 of file lsapilib.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
LSAPI_STATE_IDLE 
LSAPI_STATE_CONNECTED 
LSAPI_STATE_ACCEPTING 

Definition at line 123 of file lsapilib.c.

Function Documentation

◆ compareValueLocation()

int compareValueLocation ( const void * v1,
const void * v2 )

Definition at line 2267 of file lsapilib.c.

◆ Flush_RespBuf_r()

void Flush_RespBuf_r ( LSAPI_Request * pReq)

Definition at line 2058 of file lsapilib.c.

◆ is_enough_free_mem()

int is_enough_free_mem ( void )

Definition at line 3132 of file lsapilib.c.

◆ LSAPI_Accept_Before_Fork()

int LSAPI_Accept_Before_Fork ( LSAPI_Request * pReq)

Definition at line 3418 of file lsapilib.c.

◆ LSAPI_Accept_r()

int LSAPI_Accept_r ( LSAPI_Request * pReq)

Definition at line 1532 of file lsapilib.c.

◆ LSAPI_AppendRespHeader2_r()

int LSAPI_AppendRespHeader2_r ( LSAPI_Request * pReq,
const char * pHeaderName,
const char * pHeaderValue )

Definition at line 2494 of file lsapilib.c.

◆ LSAPI_AppendRespHeader_r()

int LSAPI_AppendRespHeader_r ( LSAPI_Request * pReq,
const char * pBuf,
int len )

Definition at line 2550 of file lsapilib.c.

◆ LSAPI_CreateListenSock()

int LSAPI_CreateListenSock ( const char * pBind,
int backlog )

Definition at line 2731 of file lsapilib.c.

◆ LSAPI_CreateListenSock2()

int LSAPI_CreateListenSock2 ( const struct sockaddr * pServerAddr,
int backlog )

Definition at line 2585 of file lsapilib.c.

◆ LSAPI_End_Response_r()

int LSAPI_End_Response_r ( LSAPI_Request * pReq)

Definition at line 1629 of file lsapilib.c.

◆ LSAPI_ErrResponse_r()

int LSAPI_ErrResponse_r ( LSAPI_Request * pReq,
int code,
const char ** pRespHeaders,
const char * pBody,
int bodyLen )

Definition at line 4103 of file lsapilib.c.

◆ LSAPI_FinalizeRespHeaders_r()

int LSAPI_FinalizeRespHeaders_r ( LSAPI_Request * pReq)

Definition at line 2467 of file lsapilib.c.

◆ LSAPI_Finish_r()

int LSAPI_Finish_r ( LSAPI_Request * pReq)

Definition at line 1599 of file lsapilib.c.

◆ LSAPI_Flush_r()

int LSAPI_Flush_r ( LSAPI_Request * pReq)

Definition at line 2082 of file lsapilib.c.

◆ LSAPI_ForeachEnv_r()

int LSAPI_ForeachEnv_r ( LSAPI_Request * pReq,
LSAPI_CB_EnvHandler fn,
void * arg )

Definition at line 2437 of file lsapilib.c.

◆ LSAPI_ForeachHeader_r()

int LSAPI_ForeachHeader_r ( LSAPI_Request * pReq,
LSAPI_CB_EnvHandler fn,
void * arg )

Definition at line 2350 of file lsapilib.c.

◆ LSAPI_ForeachOrgHeader_r()

int LSAPI_ForeachOrgHeader_r ( LSAPI_Request * pReq,
LSAPI_CB_EnvHandler fn,
void * arg )

Definition at line 2274 of file lsapilib.c.

◆ LSAPI_ForeachSpecialEnv_r()

int LSAPI_ForeachSpecialEnv_r ( LSAPI_Request * pReq,
LSAPI_CB_EnvHandler fn,
void * arg )

Definition at line 2451 of file lsapilib.c.

◆ LSAPI_Get_ppid()

int LSAPI_Get_ppid ( void )

Definition at line 3800 of file lsapilib.c.

◆ LSAPI_Get_Slow_Req_Msecs()

int LSAPI_Get_Slow_Req_Msecs ( void )

Definition at line 3788 of file lsapilib.c.

◆ LSAPI_GetEnv_r()

char * LSAPI_GetEnv_r ( LSAPI_Request * pReq,
const char * name )

Definition at line 2238 of file lsapilib.c.

◆ LSAPI_GetHeader_r()

char * LSAPI_GetHeader_r ( LSAPI_Request * pReq,
int headerIndex )

Definition at line 1689 of file lsapilib.c.

◆ LSAPI_Inc_Req_Processed()

int LSAPI_Inc_Req_Processed ( int cnt)

Definition at line 4360 of file lsapilib.c.

◆ LSAPI_Init()

int LSAPI_Init ( void )

Definition at line 1435 of file lsapilib.c.

◆ LSAPI_Init_Env_Parameters()

int LSAPI_Init_Env_Parameters ( fn_select_t fp)

Definition at line 3960 of file lsapilib.c.

◆ LSAPI_Init_Prefork_Server()

int LSAPI_Init_Prefork_Server ( int max_children,
fn_select_t fp,
int avoidFork )

Definition at line 2766 of file lsapilib.c.

◆ LSAPI_InitRequest()

int LSAPI_InitRequest ( LSAPI_Request * pReq,
int fd )

Definition at line 1481 of file lsapilib.c.

◆ LSAPI_Is_Listen()

int LSAPI_Is_Listen ( void )

Definition at line 1520 of file lsapilib.c.

◆ LSAPI_Is_Listen_r()

int LSAPI_Is_Listen_r ( LSAPI_Request * pReq)

Definition at line 1526 of file lsapilib.c.

◆ LSAPI_is_suEXEC_Daemon()

int LSAPI_is_suEXEC_Daemon ( void )

Definition at line 900 of file lsapilib.c.

◆ LSAPI_IsRunning()

int LSAPI_IsRunning ( void )

Definition at line 1469 of file lsapilib.c.

◆ LSAPI_Log()

void LSAPI_Log ( int flag,
const char * fmt,
... )

Definition at line 242 of file lsapilib.c.

◆ lsapi_MD5Final()

void lsapi_MD5Final ( unsigned char digest[16],
struct lsapi_MD5Context * context )

Definition at line 4209 of file lsapilib.c.

◆ lsapi_MD5Init()

void lsapi_MD5Init ( struct lsapi_MD5Context * context)

Definition at line 4145 of file lsapilib.c.

◆ lsapi_MD5Update()

void lsapi_MD5Update ( struct lsapi_MD5Context * context,
unsigned char const * buf,
unsigned len )

Definition at line 4160 of file lsapilib.c.

◆ LSAPI_No_Check_ppid()

void LSAPI_No_Check_ppid ( void )

Definition at line 3794 of file lsapilib.c.

◆ LSAPI_ParseSockAddr()

int LSAPI_ParseSockAddr ( const char * pBind,
struct sockaddr * pAddr )

Definition at line 2633 of file lsapilib.c.

◆ lsapi_perror()

void lsapi_perror ( const char * pMessage,
int err_no )

Definition at line 299 of file lsapilib.c.

◆ LSAPI_Postfork_Child()

int LSAPI_Postfork_Child ( LSAPI_Request * pReq)

Definition at line 3362 of file lsapilib.c.

◆ LSAPI_Postfork_Parent()

int LSAPI_Postfork_Parent ( LSAPI_Request * pReq)

Definition at line 3403 of file lsapilib.c.

◆ LSAPI_Prefork_Accept_r()

int LSAPI_Prefork_Accept_r ( LSAPI_Request * pReq)

Definition at line 3562 of file lsapilib.c.

◆ LSAPI_ReadReqBody_r()

ssize_t LSAPI_ReadReqBody_r ( LSAPI_Request * pReq,
char * pBuf,
size_t bufLen )

Definition at line 1790 of file lsapilib.c.

◆ LSAPI_Register_Pgrp_Timer_Callback()

void LSAPI_Register_Pgrp_Timer_Callback ( LSAPI_On_Timer_pf cb)

Definition at line 1475 of file lsapilib.c.

◆ LSAPI_Release_r()

int LSAPI_Release_r ( LSAPI_Request * pReq)

Definition at line 1675 of file lsapilib.c.

◆ LSAPI_ReqBodyGetChar_r()

int LSAPI_ReqBodyGetChar_r ( LSAPI_Request * pReq)

Definition at line 1729 of file lsapilib.c.

◆ LSAPI_ReqBodyGetLine_r()

int LSAPI_ReqBodyGetLine_r ( LSAPI_Request * pReq,
char * pBuf,
size_t bufLen,
int * getLF )

Definition at line 1743 of file lsapilib.c.

◆ LSAPI_Reset_r()

void LSAPI_Reset_r ( LSAPI_Request * pReq)

Definition at line 1664 of file lsapilib.c.

◆ LSAPI_reset_server_state()

void LSAPI_reset_server_state ( void )

Definition at line 2874 of file lsapilib.c.

◆ LSAPI_sendfile_r()

ssize_t LSAPI_sendfile_r ( LSAPI_Request * pReq,
int fdIn,
off_t * off,
size_t size )

Definition at line 2034 of file lsapilib.c.

◆ LSAPI_Set_Extra_Children()

void LSAPI_Set_Extra_Children ( int extraChildren)

Definition at line 3754 of file lsapilib.c.

◆ LSAPI_Set_Max_Children()

void LSAPI_Set_Max_Children ( int maxChildren)

Definition at line 3747 of file lsapilib.c.

◆ LSAPI_Set_Max_Idle()

void LSAPI_Set_Max_Idle ( int secs)

Definition at line 3743 of file lsapilib.c.

◆ LSAPI_Set_Max_Idle_Children()

void LSAPI_Set_Max_Idle_Children ( int maxIdleChld)

Definition at line 3768 of file lsapilib.c.

◆ LSAPI_Set_Max_Process_Time()

void LSAPI_Set_Max_Process_Time ( int secs)

Definition at line 3761 of file lsapilib.c.

◆ LSAPI_Set_Max_Reqs()

void LSAPI_Set_Max_Reqs ( int reqs)

Definition at line 3740 of file lsapilib.c.

◆ LSAPI_Set_Restored_Parent_Pid()

int LSAPI_Set_Restored_Parent_Pid ( int pid)

Definition at line 4352 of file lsapilib.c.

◆ LSAPI_Set_Server_fd()

void LSAPI_Set_Server_fd ( int fd)

Definition at line 2808 of file lsapilib.c.

◆ LSAPI_Set_Server_Max_Idle_Secs()

void LSAPI_Set_Server_Max_Idle_Secs ( int serverMaxIdle)

Definition at line 3775 of file lsapilib.c.

◆ LSAPI_Set_Slow_Req_Msecs()

void LSAPI_Set_Slow_Req_Msecs ( int msecs)

Definition at line 3782 of file lsapilib.c.

◆ LSAPI_Stop()

void LSAPI_Stop ( void )

Definition at line 1463 of file lsapilib.c.

◆ LSAPI_Write_r()

ssize_t LSAPI_Write_r ( LSAPI_Request * pReq,
const char * pBuf,
size_t len )

Definition at line 1839 of file lsapilib.c.

◆ LSAPI_Write_Stderr_r()

ssize_t LSAPI_Write_Stderr_r ( LSAPI_Request * pReq,
const char * pBuf,
size_t len )

Definition at line 2125 of file lsapilib.c.

◆ set_skip_write()

void set_skip_write ( void )

Definition at line 3128 of file lsapilib.c.

Variable Documentation

◆ environ

char** environ
extern

◆ g_req

Initial value:
=
{ .m_fdListen = -1, .m_fd = -1 }

Definition at line 173 of file lsapilib.c.