diff --git a/addon/example/hellohandler.c b/addon/example/hellohandler.c index 1d5c61a22..6cf3d860d 100644 --- a/addon/example/hellohandler.c +++ b/addon/example/hellohandler.c @@ -32,9 +32,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../include/ls.h" #define MNAME hellohandler -struct lsi_module_t MNAME; +lsi_module_t MNAME; -int handlerBeginProcess(void *session) +int handlerBeginProcess(lsi_session_t session) { g_api->set_status_code(session, 200); g_api->set_resp_header(session, LSI_RESP_HEADER_CONTENT_TYPE, NULL, 0, "text/html", 9, LSI_HEADER_SET ); diff --git a/addon/example/hellohandler2.c b/addon/example/hellohandler2.c index c2443ecb5..59d39c0d4 100644 --- a/addon/example/hellohandler2.c +++ b/addon/example/hellohandler2.c @@ -33,9 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "../include/ls.h" #include #define MNAME hellohandler2 -struct lsi_module_t MNAME; +lsi_module_t MNAME; -int reg_handler(struct lsi_cb_param_t *rec) +static int reg_handler(lsi_cb_param_t * rec) { const char *uri; int len; @@ -56,11 +56,11 @@ static int _init( lsi_module_t * pModule ) return 0; } -int handlerBeginProcess(void *session) +static int handlerBeginProcess(lsi_session_t session) { g_api->append_resp_body( session, "Hello module handler2.\r\n", 24 ); g_api->end_resp(session); - g_api->session_log(session, LSI_LOG_DEBUG, "[hellohandler2:%s] handlerBeginProcess fot URI: %s\n", + g_api->session_log(session, LSI_LOG_DEBUG, "[hellohandler2:%s] handlerBeginProcess fot URI: %s\n", MNAME._info, g_api->get_req_uri(session, NULL)); return 0; } diff --git a/addon/example/httpcompress.c b/addon/example/httpcompress.c index 020f9a4de..266fda954 100644 --- a/addon/example/httpcompress.c +++ b/addon/example/httpcompress.c @@ -81,15 +81,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //#define GZIP_TWO_HOOK_IMPL -struct lsi_module_t MNAME; +lsi_module_t MNAME; -//static int isCompressible( void *session, +//static int isCompressible( lsi_session_t session, #ifdef GZIP_HOOK_IMPL -static int httpCompress( struct lsi_cb_param_t *param ) +static int httpCompress( lsi_cb_param_t *param ) { - void *session = param->_session; + lsi_session_t session = param->_session; int iPtrLen, iCompressible; // NOTE: iPtrLen will be used for various purposes in this method. char pCompressed[LSI_MAX_FILE_PATH_LEN]; const char *pFilePath, @@ -135,15 +135,15 @@ lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, _init, NULL, NULL, "httpCompress" } #endif #ifdef GZIP_TWO_HOOK_IMPL -static int httpEncode( struct lsi_cb_param_t *param ) +static int httpEncode( lsi_cb_param_t *param ) { g_api->set_resp_header(param->_session, LSI_RESP_HEADER_CONTENT_ENCODING, "Content-Encoding", 16, "gzip", 4, LSI_HEADER_SET); return LSI_RET_OK; } -static int httpCompress( struct lsi_cb_param_t *param ) +static int httpCompress( lsi_cb_param_t *param ) { - void *session = param->_session; + lsi_session_t session = param->_session; int iPtrLen, iUriLen, iCompressible; // NOTE: iPtrLen will be used for various purposes in this method. char pDocPath[LSI_MAX_FILE_PATH_LEN], *ptr; const char *pReqUri = g_api->get_req_uri( session, &iUriLen ), diff --git a/addon/example/imgresize.c b/addon/example/imgresize.c index 83b8da8fd..82fbb6c46 100644 --- a/addon/example/imgresize.c +++ b/addon/example/imgresize.c @@ -56,7 +56,7 @@ enum httpimg IMAGE_TYPE; #define MNAME imgresize ///////////////////////////////////////////////////////////////////////////// -struct lsi_module_t MNAME; +lsi_module_t MNAME; #define MAX_BLOCK_BUFSIZE 8192 typedef struct _MyData @@ -67,10 +67,10 @@ typedef struct _MyData } MyData; /*Function Declarations*/ -static int setWaitFull( struct lsi_cb_param_t *rec ); -static int scanForImage( struct lsi_cb_param_t *rec ); -static int parseParameters( struct lsi_cb_param_t *rec ); -static int writeToNextFilter( struct lsi_cb_param_t *rec, MyData *myData ); +static int setWaitFull( lsi_cb_param_t * rec ); +static int scanForImage( lsi_cb_param_t * rec ); +static int parseParameters( lsi_cb_param_t * rec ); +static int writeToNextFilter( lsi_cb_param_t * rec, MyData *myData ); static int getReqDimensions( const char *buf, int *width, int *height ); static void* resizeImage( const char *buf, int bufLen, int width, int height, MyData *myData, int *size ); static int _init(); @@ -90,7 +90,7 @@ int httpRelease(void *data) return 0; } -int httpinit(struct lsi_cb_param_t *rec) +int httpinit(lsi_cb_param_t * rec) { MyData *myData = (MyData *)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_HTTP); if (myData == NULL ) @@ -114,13 +114,13 @@ int httpinit(struct lsi_cb_param_t *rec) return 0; } -static int setWaitFull( struct lsi_cb_param_t *rec ) +static int setWaitFull( lsi_cb_param_t * rec ) { g_api->set_resp_wait_full_body( rec->_session ); return LSI_RET_OK; } -static int scanForImage( struct lsi_cb_param_t *rec ) +static int scanForImage( lsi_cb_param_t * rec ) { MyData *myData = NULL; int iLen, inLen, iWidth = 0, iHeight = 0; @@ -152,7 +152,7 @@ static int scanForImage( struct lsi_cb_param_t *rec ) } /* Returns 0 for image, 1 for wrong input */ -static int parseParameters( struct lsi_cb_param_t *rec ) +static int parseParameters( lsi_cb_param_t * rec ) { int iLen; const char *ptr; @@ -178,7 +178,7 @@ static int parseParameters( struct lsi_cb_param_t *rec ) return 0; } -static int writeToNextFilter( struct lsi_cb_param_t *rec, MyData *myData ) +static int writeToNextFilter( lsi_cb_param_t * rec, MyData *myData ) { int iBytesWritten; _loopbuff_reorder(&myData->outWBuf); @@ -239,7 +239,7 @@ static void *resizeImage( const char *buf, int bufLen, int width, int height, My return ptr; } -static int scanDynamic( struct lsi_cb_param_t *rec ) +static int scanDynamic( lsi_cb_param_t * rec ) { off_t offset = 0; int iSrcSize, iDestSize, iWidth, iHeight, iLen = 0; diff --git a/addon/example/mytest.c b/addon/example/mytest.c index da2aaef17..a42ffbf6f 100644 --- a/addon/example/mytest.c +++ b/addon/example/mytest.c @@ -33,9 +33,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #define MNAME mytest -struct lsi_module_t MNAME; +lsi_module_t MNAME; -static int reg_handler(struct lsi_cb_param_t *rec) +static int reg_handler(lsi_cb_param_t * rec) { const char *uri; int len; @@ -53,13 +53,13 @@ static int _init() return 0; } -static int beginProcess(void *session) +static int beginProcess(lsi_session_t session) { g_api->append_resp_body( session, "MyTest!", 7 ); g_api->end_resp(session); return 0; } -struct lsi_handler_t myhandler = { beginProcess, NULL, NULL, NULL }; +lsi_handler_t myhandler = { beginProcess, NULL, NULL, NULL }; lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, _init, &myhandler, NULL, }; diff --git a/addon/example/replybigbufhandler.c b/addon/example/replybigbufhandler.c index 0dc817aa0..b1a75e5e7 100644 --- a/addon/example/replybigbufhandler.c +++ b/addon/example/replybigbufhandler.c @@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define MNAME replybigbufhandler ///////////////////////////////////////////////////////////////////////////// -struct lsi_module_t MNAME; +lsi_module_t MNAME; #define REPLY_BUFFER_LENGTH (1*1024*1024) /** @@ -57,7 +57,7 @@ static int freeMydata(void *data) return 0; } -static int reg_handler(struct lsi_cb_param_t *rec) +static int reg_handler(lsi_cb_param_t * rec) { const char *uri; int len; @@ -84,7 +84,7 @@ static int init( lsi_module_t * pModule) } //The first time the below function will be called, then onWriteEvent will be called next and next -static int myhandler_process(void *session) +static int myhandler_process(lsi_session_t session) { g_api->set_resp_header(session, LSI_RESP_HEADER_CONTENT_TYPE, NULL, 0, "text/html", 9, LSI_HEADER_SET ); int writeSize = sizeof("replybigbufhandler module reply the first line\r\n") - 1; @@ -97,7 +97,7 @@ static int myhandler_process(void *session) } //return 0: error, 1: done, 2: not finished, definitions are in ls.h -static int onWriteEvent( void *session) +static int onWriteEvent( lsi_session_t session) { #define BLOACK_SIZE (1024) int i; @@ -123,5 +123,5 @@ static int onWriteEvent( void *session) return LSI_WRITE_RESP_FINISHED; } -struct lsi_handler_t myhandler = { myhandler_process, NULL, onWriteEvent, NULL }; +lsi_handler_t myhandler = { myhandler_process, NULL, onWriteEvent, NULL }; lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, init, &myhandler, NULL, }; diff --git a/addon/example/reqinfhandler.c b/addon/example/reqinfhandler.c index 784cae096..5b059f1c6 100644 --- a/addon/example/reqinfhandler.c +++ b/addon/example/reqinfhandler.c @@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define TESTURI "/reqinfo" -struct lsi_module_t MNAME; +lsi_module_t MNAME; typedef struct _MyData { @@ -81,7 +81,7 @@ static int releaseData(void *data) return 0; } -static int resetData(struct lsi_cb_param_t *rec) +static int resetData(lsi_cb_param_t * rec) { MyData *myData = (MyData *)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_HTTP); if (myData) @@ -91,7 +91,7 @@ static int resetData(struct lsi_cb_param_t *rec) return 0; } -static int initData(struct lsi_cb_param_t *rec) +static int initData(lsi_cb_param_t * rec) { MyData *myData = (MyData *)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_HTTP); if (!myData) @@ -103,7 +103,7 @@ static int initData(struct lsi_cb_param_t *rec) return 0; } -static int check_uri_and_reg_handler(struct lsi_cb_param_t *rec) +static int check_uri_and_reg_handler(lsi_cb_param_t * rec) { const char *uri; int len; @@ -125,7 +125,7 @@ static int _init( lsi_module_t * pModule ) } //0:no body or no deal, 1,echo, 2: md5, 3, save to file -static int getReqBodyDealerType(void *session) +static int getReqBodyDealerType(lsi_session_t session) { char path[512]; int n; @@ -290,7 +290,7 @@ const char *reqHeaderArray[] = { "X-Forwarded-For", }; -static inline void append( void *session, const char *s, int n) +static inline void append( lsi_session_t session, const char *s, int n) { if ( n == 0) n = strlen(s); @@ -301,7 +301,7 @@ static inline void append( void *session, const char *s, int n) #define CONTENT_HEAD "Server request varibles\r\n" #define CONTENT_FORMAT "%s%s\r\n" #define CONTENT_TAIL "\r\n" -static int handleReqBody( void *session) +static int handleReqBody( lsi_session_t session) { unsigned char md5[16]; char buf[8192]; @@ -379,7 +379,7 @@ static int handleReqBody( void *session) return readbytes; } -static int handlerBeginProcess( void *session) +static int handlerBeginProcess( lsi_session_t session) { #define VALMAXSIZE 512 #define LINEMAXSIZE (VALMAXSIZE + 50) @@ -502,13 +502,13 @@ static int handlerBeginProcess( void *session) return 0; } -static int cleanUp( void *session) +static int cleanUp( lsi_session_t session) { g_api->free_module_data(session, &MNAME, LSI_MODULE_DATA_HTTP, releaseData); return 0; } -static int handlerWriteRemainResp( void *session) +static int handlerWriteRemainResp( lsi_session_t session) { MyData *myData = (MyData *)g_api->get_module_data(session, &MNAME, LSI_MODULE_DATA_HTTP); if ( myData == NULL || myData->type == 0 || myData->resp_done == 1) @@ -518,7 +518,7 @@ static int handlerWriteRemainResp( void *session) return LSI_WRITE_RESP_CONTINUE; } -struct lsi_handler_t reqHandler = { handlerBeginProcess, handleReqBody, handlerWriteRemainResp, cleanUp }; +lsi_handler_t reqHandler = { handlerBeginProcess, handleReqBody, handlerWriteRemainResp, cleanUp }; lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, _init, &reqHandler, NULL, }; diff --git a/addon/example/reqobservmodule.c b/addon/example/reqobservmodule.c index 50db90f24..3a7a02beb 100644 --- a/addon/example/reqobservmodule.c +++ b/addon/example/reqobservmodule.c @@ -56,7 +56,7 @@ const char *blockWords[] = { "badword3", }; -struct lsi_module_t MNAME; +lsi_module_t MNAME; static int hasBadWord(const char *s, size_t len) { @@ -75,7 +75,7 @@ static int hasBadWord(const char *s, size_t len) } -int check_req_whole_body(struct lsi_cb_param_t *rec) +int check_req_whole_body(lsi_cb_param_t * rec) { off_t offset = 0; const char * pBuf; diff --git a/addon/example/sendfilehandler.c b/addon/example/sendfilehandler.c index c7e212f45..4f9b67d07 100644 --- a/addon/example/sendfilehandler.c +++ b/addon/example/sendfilehandler.c @@ -42,8 +42,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define MNAME sendfilehandler ///////////////////////////////////////////////////////////////////////////// -struct lsi_module_t MNAME; -int dummycall(struct lsi_cb_param_t *rec) +lsi_module_t MNAME; +int dummycall(lsi_cb_param_t * rec) { const char *in = (const char *)rec->_param; int inLen = rec->_param_len; @@ -51,7 +51,7 @@ int dummycall(struct lsi_cb_param_t *rec) return sent; } -int reg_handler(struct lsi_cb_param_t *rec) +int reg_handler(lsi_cb_param_t * rec) { const char *uri; int len; @@ -71,7 +71,7 @@ static int init(lsi_module_t * pModule) } -static int myhandler_process(void *session) +static int myhandler_process(lsi_session_t session) { struct stat sb; const char *file = "/home/user/ls0312/DEFAULT/html/test1"; @@ -97,5 +97,5 @@ static int myhandler_process(void *session) return 0; } -struct lsi_handler_t myhandler = { myhandler_process, NULL, NULL, NULL }; +lsi_handler_t myhandler = { myhandler_process, NULL, NULL, NULL }; lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, init, &myhandler, NULL, }; diff --git a/addon/example/setrespheader.c b/addon/example/setrespheader.c index b925d196b..64f9eb7dc 100644 --- a/addon/example/setrespheader.c +++ b/addon/example/setrespheader.c @@ -49,11 +49,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define TEST_URL "setrespheader" -struct lsi_module_t MNAME; +lsi_module_t MNAME; //test changing resp header -static int mycb(struct lsi_cb_param_t *rec) +static int mycb(lsi_cb_param_t * rec) { g_api->set_resp_header(rec->_session, LSI_RESP_HEADER_SERVER, NULL, 0, "/testServer 1.0", sizeof("/testServer 1.0") - 1, LSI_HEADER_SET); g_api->set_resp_header(rec->_session, LSI_RESP_HEADER_SET_COOKIE, NULL, 0, "my-test-cookie1", sizeof("my-test-cookie1") - 1, LSI_HEADER_ADD); @@ -63,13 +63,13 @@ static int mycb(struct lsi_cb_param_t *rec) } //test changing resp header -static int mycb2(struct lsi_cb_param_t *rec) +static int mycb2(lsi_cb_param_t * rec) { g_api->set_resp_header2(rec->_session, "Addheader: MyTest addtional header2\r\n", sizeof("Addheader: MyTest addtional header2\r\n") -1, LSI_HEADER_SET); return 0; } -int check_if_remove_session_hook(struct lsi_cb_param_t *rec) +int check_if_remove_session_hook(lsi_cb_param_t * rec) { const char *qs; int sessionHookType = 0; diff --git a/addon/example/testenv.c b/addon/example/testenv.c index 889bcff3f..a2b087eb2 100644 --- a/addon/example/testenv.c +++ b/addon/example/testenv.c @@ -38,7 +38,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #define MNAME testenv -struct lsi_module_t MNAME; +lsi_module_t MNAME; #define URI_PREFIX "/testenv" #define max_file_len 1024 @@ -48,7 +48,7 @@ struct lsi_module_t MNAME; * //testenv?modcompress:S1P-3000R1P-3000&moddecompress:S1P3000R1P3000 */ -int assignHandler(struct lsi_cb_param_t *rec) +int assignHandler(lsi_cb_param_t * rec) { int len; const char *p; @@ -105,7 +105,7 @@ int assignHandler(struct lsi_cb_param_t *rec) return 0; } -static int myhandler_process(void *session) +static int myhandler_process(lsi_session_t session) { int i; //200KB @@ -126,5 +126,5 @@ static int _init(lsi_module_t * pModule) return 0; } -struct lsi_handler_t myhandler = { myhandler_process, NULL, NULL, NULL }; +lsi_handler_t myhandler = { myhandler_process, NULL, NULL, NULL }; lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, _init, &myhandler, NULL, }; diff --git a/addon/example/testmoduledata.c b/addon/example/testmoduledata.c index d750803c7..fe2fe245e 100644 --- a/addon/example/testmoduledata.c +++ b/addon/example/testmoduledata.c @@ -55,7 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #define MNAME testmoduledata -struct lsi_module_t MNAME; +lsi_module_t MNAME; #define URI_PREFIX "/testmoduledata" #define max_file_len 1024 @@ -75,7 +75,7 @@ int releaseCounterDataCb( void *data ) return 0; } -CounterData *allocateMydata(void *session, const lsi_module_t *module, int level) +CounterData *allocateMydata(lsi_session_t session, const lsi_module_t *module, int level) { CounterData *myData = (CounterData*)malloc(sizeof(CounterData)); if (myData == NULL ) @@ -86,7 +86,7 @@ CounterData *allocateMydata(void *session, const lsi_module_t *module, int level return myData; } -int assignHandler(struct lsi_cb_param_t *rec) +int assignHandler(lsi_cb_param_t * rec) { const char *p; char path[max_file_len] = {0}; @@ -114,7 +114,7 @@ int assignHandler(struct lsi_cb_param_t *rec) return 0; } -static int myhandler_process(void *session) +static int myhandler_process(lsi_session_t session) { CounterData *ip_data = NULL, *vhost_data = NULL, *file_data = NULL; char output[128]; @@ -159,5 +159,5 @@ static int _init(lsi_module_t * pModule) return 0; } -struct lsi_handler_t myhandler = { myhandler_process, NULL, NULL, NULL }; +lsi_handler_t myhandler = { myhandler_process, NULL, NULL, NULL }; lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, _init, &myhandler, NULL, }; diff --git a/addon/example/testparam.c b/addon/example/testparam.c index 477f21ba7..b587da567 100644 --- a/addon/example/testparam.c +++ b/addon/example/testparam.c @@ -58,7 +58,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. **********************************************************************/ #define MNAME testparam -struct lsi_module_t MNAME; +lsi_module_t MNAME; typedef struct _param_st{ int param1; @@ -101,7 +101,7 @@ const char *myParam[] = { NULL //The last position must have a NULL to indicate end of the array }; -static void * testparam_parseConfig( const char *param, void *_initial_config ) +static void * testparam_parseConfig( const char *param, void *_initial_config, int level, const char *name ) { param_st *pInitConfig = (param_st *)_initial_config; param_st *pConfig = (param_st *) malloc(sizeof(struct _param_st)); @@ -144,7 +144,7 @@ static void testparam_freeConfig(void *_config) free(_config); } -static int testparam_handlerBeginProcess(void *session) +static int testparam_handlerBeginProcess(lsi_session_t session) { g_api->set_resp_header(session, LSI_RESP_HEADER_CONTENT_TYPE, NULL, 0, "text/plain", sizeof("text/plain") - 1, LSI_HEADER_SET ); @@ -168,7 +168,7 @@ static int testparam_handlerBeginProcess(void *session) return 0; } -static int reg_handler(struct lsi_cb_param_t *rec) +static int reg_handler(lsi_cb_param_t * rec) { const char *uri; int len; @@ -196,6 +196,6 @@ static int testparam_init(lsi_module_t * pModule) return 0; } -struct lsi_handler_t testparam_myhandler = { testparam_handlerBeginProcess, NULL, NULL, NULL }; -struct lsi_config_t testparam_dealConfig = { testparam_parseConfig, testparam_freeConfig, myParam }; +lsi_handler_t testparam_myhandler = { testparam_handlerBeginProcess, NULL, NULL, NULL }; +lsi_config_t testparam_dealConfig = { testparam_parseConfig, testparam_freeConfig, myParam }; lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, testparam_init, &testparam_myhandler, &testparam_dealConfig, "Version 1.1" }; diff --git a/addon/example/testredirect.c b/addon/example/testredirect.c index abe99474a..fcc78a4c8 100644 --- a/addon/example/testredirect.c +++ b/addon/example/testredirect.c @@ -39,9 +39,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -struct lsi_module_t MNAME; +lsi_module_t MNAME; -int check_if_redirect(struct lsi_cb_param_t *rec) +int check_if_redirect(lsi_cb_param_t * rec) { const char *uri; const char *qs; @@ -67,7 +67,7 @@ static int _init( lsi_module_t * pModule ) return 0; } -static int handlerBeginProcess(void *session) +static int handlerBeginProcess(lsi_session_t session) { const char *qs; int action = LSI_URI_REWRITE; @@ -77,5 +77,5 @@ static int handlerBeginProcess(void *session) return 0; } -struct lsi_handler_t myhandler = { handlerBeginProcess, NULL, NULL, NULL }; +lsi_handler_t myhandler = { handlerBeginProcess, NULL, NULL, NULL }; lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, _init, &myhandler, NULL, "test redirect v1.0" }; diff --git a/addon/example/testtimer.c b/addon/example/testtimer.c index 1eb62175f..42fd0a131 100644 --- a/addon/example/testtimer.c +++ b/addon/example/testtimer.c @@ -51,10 +51,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define MNAME testtimer ///////////////////////////////////////////////////////////////////////////// -struct lsi_module_t MNAME; -static int onReadEvent( void *session); +lsi_module_t MNAME; +static int onReadEvent( lsi_session_t session); -int reg_handler(struct lsi_cb_param_t *rec) +int reg_handler(lsi_cb_param_t * rec) { const char *uri; int len; @@ -73,16 +73,16 @@ static int init(lsi_module_t * pModule ) return 0; } -void timer_callback(void *session) +void timer_callback(void * session) { char buf[1024]; sprintf(buf, "timer triggered and cotinue to write, time: %ld", (long)(time(NULL))); - g_api->append_resp_body(session, buf, strlen(buf)); - g_api->set_handler_write_state(session, 1); + g_api->append_resp_body((lsi_session_t)session, buf, strlen(buf)); + g_api->set_handler_write_state((lsi_session_t)session, 1); } //The first time the below function will be called, then onWriteEvent will be called next and next -static int myhandler_process(void *session) +static int myhandler_process(lsi_session_t session) { char tmBuf[30]; time_t t; @@ -103,7 +103,7 @@ static int myhandler_process(void *session) return 0; } -static int onReadEvent( void *session) +static int onReadEvent( lsi_session_t session) { char buf[8192]; g_api->append_resp_body(session, "I got req body:
", sizeof("I got req body:
") -1 ); @@ -113,11 +113,11 @@ static int onReadEvent( void *session) return 0; } -static int onWriteEvent( void *session) +static int onWriteEvent( lsi_session_t session) { g_api->append_resp_body(session, "
Written finished and bye.

", sizeof("
Written finished and bye.

") -1 ); return LSI_WRITE_RESP_FINISHED; } -struct lsi_handler_t myhandler = { myhandler_process, onReadEvent, onWriteEvent, NULL }; +lsi_handler_t myhandler = { myhandler_process, onReadEvent, onWriteEvent, NULL }; lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, init, &myhandler, NULL, }; diff --git a/addon/example/updatehttpout.c b/addon/example/updatehttpout.c index 2fdb0405c..9adbccc45 100644 --- a/addon/example/updatehttpout.c +++ b/addon/example/updatehttpout.c @@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define TEST_STRING "_TEST_testmodule_ADD_A_STRING_HERE_" ///////////////////////////////////////////////////////////////////////////// -struct lsi_module_t MNAME; +lsi_module_t MNAME; #define MAX_BLOCK_BUFSIZE 8192 typedef struct _MyData @@ -68,7 +68,7 @@ int httpRelease(void *data) return 0; } -int httpinit(struct lsi_cb_param_t *rec) +int httpinit(lsi_cb_param_t * rec) { MyData *myData = (MyData *)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_HTTP); if (myData == NULL ) @@ -91,7 +91,7 @@ int httpinit(struct lsi_cb_param_t *rec) return 0; } -int httprespwrite(struct lsi_cb_param_t *rec) +int httprespwrite(lsi_cb_param_t * rec) { MyData *myData = NULL; const char *in = rec->_param; @@ -138,7 +138,7 @@ static char *getNullEndString(const char *s, int len, char *str, int maxLength) } -int httpreqHeaderRecved(struct lsi_cb_param_t *rec) +int httpreqHeaderRecved(lsi_cb_param_t * rec) { const char *host, *ua, *uri, *accept; char *headerBuf; diff --git a/addon/example/updatetcpin1.c b/addon/example/updatetcpin1.c index cb18b1261..26e741896 100644 --- a/addon/example/updatetcpin1.c +++ b/addon/example/updatetcpin1.c @@ -137,7 +137,7 @@ int Base64_encode( const char *decoded, int size, char * encoded ) #define MNAME updatetcpin1 ///////////////////////////////////////////////////////////////////////////// -struct lsi_module_t MNAME; +lsi_module_t MNAME; #define MAX_BLOCK_BUFSIZE 8192 typedef struct _MyData @@ -162,7 +162,7 @@ int l4release(void *data) } -int l4init1( struct lsi_cb_param_t * rec ) +int l4init1( lsi_cb_param_t * rec ) { MyData *myData = (MyData *)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_L4); if (!myData) @@ -186,7 +186,7 @@ int l4init1( struct lsi_cb_param_t * rec ) } //expand the recieved data to base64 encode -int l4recv1(struct lsi_cb_param_t * rec) +int l4recv1(lsi_cb_param_t * rec) { #define PLAIN_BLOCK_SIZE 600 #define ENCODE_BLOCK_SIZE (PLAIN_BLOCK_SIZE * 4 / 3 + 1) diff --git a/addon/example/updatetcpin2.c b/addon/example/updatetcpin2.c index 773faaf7f..30e650eaa 100644 --- a/addon/example/updatetcpin2.c +++ b/addon/example/updatetcpin2.c @@ -137,7 +137,7 @@ int Base64_encode( const char *decoded, int size, char * encoded ) #define MNAME updatetcpin2 ///////////////////////////////////////////////////////////////////////////// -struct lsi_module_t MNAME; +lsi_module_t MNAME; #define MAX_BLOCK_BUFSIZE 8192 typedef struct _MyData2 @@ -162,7 +162,7 @@ static int l4release2(void *data) } -static int l4init2( struct lsi_cb_param_t * rec ) +static int l4init2( lsi_cb_param_t * rec ) { MyData2 *myData = (MyData2 *)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_L4); if (!myData) @@ -186,7 +186,7 @@ static int l4init2( struct lsi_cb_param_t * rec ) } //expand the recieved data to base64 encode -static int l4recv2(struct lsi_cb_param_t * rec) +static int l4recv2(lsi_cb_param_t * rec) { #define ENCODE_BLOCK_SIZE 800 #define DECODE_BLOCK_SIZE (ENCODE_BLOCK_SIZE * 3 / 4 + 4) diff --git a/addon/example/updatetcpout1.c b/addon/example/updatetcpout1.c index adff4e71a..dc4da2fd9 100644 --- a/addon/example/updatetcpout1.c +++ b/addon/example/updatetcpout1.c @@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define MNAME updatetcpout1 ///////////////////////////////////////////////////////////////////////////// -struct lsi_module_t MNAME; +lsi_module_t MNAME; #define MAX_BLOCK_BUFSIZE 8192 typedef struct _MyData @@ -67,7 +67,7 @@ int l4release(void *data) } -int l4init( struct lsi_cb_param_t * rec ) +int l4init( lsi_cb_param_t * rec ) { MyData *myData = (MyData *)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_L4); @@ -90,7 +90,7 @@ int l4init( struct lsi_cb_param_t * rec ) return 0; } -static int l4send(struct lsi_cb_param_t * rec) +static int l4send(lsi_cb_param_t * rec) { MyData *myData = NULL; char *pBegin; diff --git a/addon/example/updatetcpout2.c b/addon/example/updatetcpout2.c index 1c815136e..4137990d5 100644 --- a/addon/example/updatetcpout2.c +++ b/addon/example/updatetcpout2.c @@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define MNAME updatetcpout2 ///////////////////////////////////////////////////////////////////////////// -struct lsi_module_t MNAME; +lsi_module_t MNAME; #define MAX_BLOCK_BUFSIZE 8192 typedef struct _MyData @@ -67,7 +67,7 @@ int l4release(void *data) } -int l4init( struct lsi_cb_param_t * rec ) +int l4init( lsi_cb_param_t * rec ) { MyData *myData = (MyData *)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_L4); @@ -90,7 +90,7 @@ int l4init( struct lsi_cb_param_t * rec ) return 0; } -int l4send(struct lsi_cb_param_t * rec) +int l4send(lsi_cb_param_t * rec) { int total = 0; diff --git a/addon/example/waitfullreqbody.c b/addon/example/waitfullreqbody.c index 03b5bca94..5bad3b38c 100644 --- a/addon/example/waitfullreqbody.c +++ b/addon/example/waitfullreqbody.c @@ -52,7 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define CONTENT_TAIL "

\r\n" -struct lsi_module_t MNAME; +lsi_module_t MNAME; #define MAX_BLOCK_BUFSIZE 8192 typedef struct _MyDatas @@ -74,7 +74,7 @@ static int httpRelease(void *data) return 0; } -static int httpinit(struct lsi_cb_param_t *rec) +static int httpinit(lsi_cb_param_t * rec) { MyData *myData = (MyData *)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_HTTP); if (myData == NULL ) @@ -100,7 +100,7 @@ static int httpinit(struct lsi_cb_param_t *rec) * DO NOT SET TO 0, because the other module may already set to 1 when pass in this function. * */ -static int httpreqread(struct lsi_cb_param_t *rec) +static int httpreqread(lsi_cb_param_t * rec) { MyData *myData = NULL; char *pBegin; @@ -157,7 +157,7 @@ static int httpreqread(struct lsi_cb_param_t *rec) } -static int check_uri_and_reg_handler(struct lsi_cb_param_t *rec) +static int check_uri_and_reg_handler(lsi_cb_param_t * rec) { const char *uri; int len; @@ -182,7 +182,7 @@ static int _init( lsi_module_t * pModule ) return 0; } -static int handleReqBody( void *session ) +static int handleReqBody( lsi_session_t session ) { char buf[MAX_BLOCK_BUFSIZE]; int ret; @@ -211,7 +211,7 @@ static int handleReqBody( void *session ) return 0; } -static int handlerBeginProcess( void *session ) +static int handlerBeginProcess( lsi_session_t session ) { g_api->set_req_wait_full_body( session ); g_api->append_resp_body(session, CONTENT_HEAD, strlen(CONTENT_HEAD)); @@ -226,11 +226,11 @@ static int handlerBeginProcess( void *session ) return 0; } -static int cleanUp( void *session) +static int cleanUp( lsi_session_t session) { g_api->free_module_data(session, &MNAME, LSI_MODULE_DATA_HTTP, httpRelease); return 0; } -struct lsi_handler_t reqHandler = { handlerBeginProcess, handleReqBody, NULL, cleanUp }; +lsi_handler_t reqHandler = { handlerBeginProcess, handleReqBody, NULL, cleanUp }; lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, _init, &reqHandler, NULL, }; diff --git a/addon/example/waitfullrespbody.c b/addon/example/waitfullrespbody.c index a7d591f00..5d1b791d5 100644 --- a/addon/example/waitfullrespbody.c +++ b/addon/example/waitfullrespbody.c @@ -43,20 +43,20 @@ lsi_module_t MNAME; #define VERSION "V1.0" -static int internalRedir(struct lsi_cb_param_t *rec) +static int internalRedir(lsi_cb_param_t * rec) { int action = LSI_URL_REDIRECT_INTERNAL; g_api->set_uri_qs(rec->_session, action, DEST_URL, sizeof(DEST_URL) -1, "", 0 ); return LSI_RET_OK; } -static int denyAccess(struct lsi_cb_param_t *rec) +static int denyAccess(lsi_cb_param_t * rec) { g_api->set_status_code( rec->_session, 406 ); return LSI_RET_ERROR; } -static int getTestType(struct lsi_cb_param_t *rec) +static int getTestType(lsi_cb_param_t * rec) { int type = 0; int len; diff --git a/addon/include/ls.h b/addon/include/ls.h index bd8da6c1c..a1c2edeb2 100644 --- a/addon/include/ls.h +++ b/addon/include/ls.h @@ -18,6 +18,7 @@ #ifndef LS_MODULE_H #define LS_MODULE_H #include +#include #include #include #include @@ -94,13 +95,23 @@ extern "C" { #endif - - - /************************************************************************************************** * API Parameter ENUMs **************************************************************************************************/ +/** + * + * + * + */ +enum lsi_config_level +{ + LSI_SERVER_LEVEL = 0, + LSI_LISTENER_LEVEL, + LSI_VHOST_LEVEL, + LSI_CONTEXT_LEVEL, +}; + /** * @enum lsi_hook_priority * @brief The default running priorities for hook filter functions. @@ -1035,13 +1046,13 @@ enum lsi_resp_header_id /* * Forward Declarations */ -struct lsi_module_t; -struct lsi_api_t; -struct lsi_cb_param_t; -struct lsi_hook_info_t; -struct lsi_gdata_cont_val_t; -struct stat; -typedef struct lsi_shm_htable_t lsi_shm_htable_t; +typedef struct lsi_module_s lsi_module_t; +typedef struct lsi_api_s lsi_api_t; +typedef struct lsi_cb_param_s lsi_cb_param_t; +typedef struct lsi_hook_info_s lsi_hook_info_t; +typedef struct lsi_gdata_cont_val_s lsi_gdata_cont_val_t; +typedef struct lsi_shm_htable_s lsi_shm_htable_t; +typedef struct lsi_session_s * lsi_session_t; typedef uint32_t lsi_shm_off_t; typedef uint32_t lsi_hash_key_t; @@ -1050,7 +1061,7 @@ typedef uint32_t lsi_hash_key_t; * @brief The callback function and its parameters. * @since 1.0 */ -typedef int ( *lsi_callback_pf) ( struct lsi_cb_param_t * ); +typedef int ( *lsi_callback_pf) ( lsi_cb_param_t * ); /** * @typedef lsi_release_callback_pf * @brief The memory release callback function for the user module data. @@ -1093,29 +1104,29 @@ typedef int (*lsi_hash_value_comp_pf) ( const void * pVal1, const void * pVal2 /** - * @struct lsi_cb_param_t + * @typedef lsi_cb_param_t * @brief Callback parameters passed to the callback functions * @since 1.0 **/ -typedef struct lsi_cb_param_t +typedef struct lsi_cb_param_s { /** * @brief _session is a pointer to the session. * @since 1.0 */ - void * _session; + lsi_session_t _session; /** * @brief _hook_info is a pointer to the struct lsi_hook_info_t. * @since 1.0 */ - struct lsi_hook_info_t * _hook_info; + lsi_hook_info_t * _hook_info; /** * @brief _cur_hook is a pointer to the current hook. * @since 1.0 */ - void * _cur_hook; + void * _cur_hook; /** * @brief _param is a pointer to the first parameter. @@ -1124,7 +1135,7 @@ typedef struct lsi_cb_param_t * of expected values for each _param based on use. * @since 1.0 */ - const void * _param; + const void * _param; /** * @brief _param_len is the length of the first parameter. @@ -1148,18 +1159,18 @@ typedef struct lsi_cb_param_t /** - * @struct lsi_handler_t + * @typedef lsi_handler_t * @brief Pre-defined handler functions * @since 1.0 */ -typedef struct lsi_handler_t +typedef struct lsi_handler_s { /** * @brief begin_process is called when the server starts to process a request. * @details It is used to define the request handler callback function. * @since 1.0 */ - int ( *begin_process ) ( void *session ); + int ( *begin_process ) ( lsi_session_t session ); /** * @brief on_read_req_body is called on a READ event with a large request body. @@ -1169,7 +1180,7 @@ typedef struct lsi_handler_t * The default function will execute and return 0. * @since 1.0 */ - int ( *on_read_req_body ) ( void *session ); + int ( *on_read_req_body ) ( lsi_session_t session ); /** * @brief on_write_resp is called on a WRITE event with a large response body. @@ -1179,7 +1190,7 @@ typedef struct lsi_handler_t * The default function will execute and return LSI_WRITE_RESP_FINISHED. * @since 1.0 */ - int ( *on_write_resp ) ( void *session ); + int ( *on_write_resp ) ( lsi_session_t session ); /** * @brief on_clean_up is called when the server core is done with the handler, ask the @@ -1189,12 +1200,12 @@ typedef struct lsi_handler_t * @since 1.0 */ - int ( *on_clean_up ) ( void *session ); + int ( *on_clean_up ) ( lsi_session_t session ); } lsi_handler_t; /** - * @struct lsi_config_t + * @typedef lsi_config_s * @brief Contains functions which are used to define parse and release functions for the * user defined configuration parameters. * @details @@ -1203,7 +1214,7 @@ typedef struct lsi_handler_t * allocated memory using the session_end filter hooks. * @since 1.0 */ -typedef struct lsi_config_t +typedef struct lsi_config_s { /** * @brief _parse_config is a callback function for the server to call to parse the user defined @@ -1213,11 +1224,13 @@ typedef struct lsi_config_t * @since 1.0 * @param[in] param - the \\0 terminated buffer holding configuration parameters. * @param[in] initial_config - a pointer to default configuration inherited from parent level + * @param[in] level - lsi_config_level //FIXME: to be updated! + * @param[in] name - name of the Server/Listener/VHost or uri of the Context * @return a pointer to a the user-defined configuration data, which combines initial_config with * settings in param, if both param and initial_config are NULL, hard-coded default * configuration value should be returned. */ - void * ( *_parse_config ) ( const char *param, void *initial_config ); + void * ( *_parse_config ) ( const char *param, void *initial_config, int level, const char *name ); /** * @brief _free_config is a callback function for the server to call to release a pointer to @@ -1241,14 +1254,13 @@ typedef struct lsi_config_t + LSI_MODULE_DATA_COUNT * sizeof( int16_t ) ) -typedef struct lsi_module_t lsi_module_t; /** - * @struct lsi_module_t + * @typedef lsi_module_t * @brief Defines an LSIAPI module, this struct must be provided in the module code. * @since 1.0 */ -struct lsi_module_t +struct lsi_module_s { /** * @brief _signature contains a function pointer that will be called after the module is loaded. @@ -1269,7 +1281,7 @@ struct lsi_module_t * If not present, set to NULL. * @since 1.0 */ - struct lsi_handler_t * _handler; + lsi_handler_t * _handler; /** * @brief _config_parser contains functions which are used to parse user defined @@ -1277,7 +1289,7 @@ struct lsi_module_t * If not present, set to NULL. * @since 1.0 */ - struct lsi_config_t * _config_parser; + lsi_config_t * _config_parser; /** @@ -1300,11 +1312,11 @@ struct lsi_module_t **************************************************************************************************/ /** - * @struct lsi_api_t + * @typedef lsi_api_t * @brief LSIAPI function set. * @since 1.0 **/ -typedef struct lsi_api_t +typedef struct lsi_api_s { /************************************************************************************************************** * SINCE LSIAPI 1.0 * @@ -1341,7 +1353,7 @@ typedef struct lsi_api_t * @param[in] level - enum defined in log level definitions. * @param[in] fmt - formatted string. */ - void ( *session_log )( void *session, int level, const char * fmt, ... ); + void ( *session_log )( lsi_session_t session, int level, const char * fmt, ... ); /** * @brief session_vlog is used to write the formatted log to error log associated with a session @@ -1355,7 +1367,7 @@ typedef struct lsi_api_t * @param[in] vararg - the varying argument list * @param[in] no_linefeed - 1 = do not add \\n at the end of message; 0 = add \\n */ - void ( *session_vlog )( void *session, int level, const char * fmt, va_list vararg, int no_linefeed ); + void ( *session_vlog )( lsi_session_t session, int level, const char * fmt, va_list vararg, int no_linefeed ); /** * @brief session_lograw is used to write additional log messages to error log file associated with a session @@ -1368,7 +1380,7 @@ typedef struct lsi_api_t * @param[in] buf - data to be written to log file. * @param[in] len - the size of data to be logged */ - void ( *session_lograw )( void *session, const char * buf, int len ); + void ( *session_lograw )( lsi_session_t session, const char * buf, int len ); /** * @brief get_module_param is used to get the user defined module parameters which are parsed by @@ -1380,7 +1392,7 @@ typedef struct lsi_api_t * @param[in] pModule - a pointer to an lsi_module_t struct. * @return a pointer to a the user-defined configuration data. */ - void * (* get_module_param)( void *session, const lsi_module_t *pModule ); + void * (* get_module_param)( lsi_session_t session, const lsi_module_t *pModule ); /** * @brief add_hook function is used to add a global level hook function. @@ -1427,7 +1439,7 @@ typedef struct lsi_api_t * This flag turns off sendfile(). * @return -1 on failure, 0 for already added, location in the filter chain on success. */ - int ( *add_session_hook )( void * session, int index, const lsi_module_t *pModule, lsi_callback_pf cb, short priority, short flag ); + int ( *add_session_hook )( lsi_session_t session, int index, const lsi_module_t *pModule, lsi_callback_pf cb, short priority, short flag ); /** * @brief remove_session_hook is used to remove a session level hook function. @@ -1442,7 +1454,7 @@ typedef struct lsi_api_t * @param[in] index - as defined in the enum of Hook Point level definitions. * @param[in] pModule - a pointer to the lsi_module_t struct. */ - int ( *remove_session_hook )( void * session, int index, const lsi_module_t *pModule ); + int ( *remove_session_hook )( lsi_session_t session, int index, const lsi_module_t *pModule ); /** * @brief get_module is used to retrieve module information associated with a hookpoint based on callback parameters. @@ -1480,7 +1492,7 @@ typedef struct lsi_api_t * @param[in] pathLen - the length of the path string. * @return -1 on failure, file descriptor on success. */ - int ( *init_file_type_mdata )( void *session, const lsi_module_t *pModule, const char *path, int pathLen ); + int ( *init_file_type_mdata )( lsi_session_t session, const lsi_module_t *pModule, const char *path, int pathLen ); /** * @brief set_module_data is used to set the module data of a session level(scope). @@ -1494,7 +1506,7 @@ typedef struct lsi_api_t * @param[in] sParam - a pointer to the user defined data. * @return -1 for bad level or no release data callback function, 0 on success. */ - int ( *set_module_data )( void *session, const lsi_module_t *pModule, int level, void *sParam ); + int ( *set_module_data )( lsi_session_t session, const lsi_module_t *pModule, int level, void *sParam ); /** * @brief get_module_data gets the module data which was set by set_module_data. @@ -1507,7 +1519,7 @@ typedef struct lsi_api_t * @param[in] level - as defined in the module data level enum. * @return NULL on failure, a pointer to the user defined data on success. */ - void * ( *get_module_data )( void *session, const lsi_module_t *pModule, int level ); + void * ( *get_module_data )( lsi_session_t session, const lsi_module_t *pModule, int level ); /** * @brief get_module_data gets the module data related to current callback. @@ -1532,7 +1544,7 @@ typedef struct lsi_api_t * @param[in] level - as defined in the module data level enum. * @param[in] cb - a pointer to the user-defined callback function that releases the user data. */ - void ( *free_module_data )( void * session, const lsi_module_t *pModule, int level, lsi_release_callback_pf cb ); + void ( *free_module_data )( lsi_session_t session, const lsi_module_t *pModule, int level, lsi_release_callback_pf cb ); /** * @brief stream_writev_next needs to be called in the LSI_HKPT_L4_SENDING hook point level just @@ -1590,7 +1602,7 @@ typedef struct lsi_api_t * @param[in] key_len - the string length. * @return NULL on failure, a pointer to the data container on success. */ - struct lsi_gdata_cont_val_t *( *get_gdata_container)( int type, const char *key, int key_len ); + lsi_gdata_cont_val_t *( *get_gdata_container)( int type, const char *key, int key_len ); /** * @brief empty_gdata_container is used to delete all the data indices in the global data container. @@ -1601,7 +1613,7 @@ typedef struct lsi_api_t * @param[in] container - the global data container. * @return -1 on failure, 0 on success. */ - int ( *empty_gdata_container )( struct lsi_gdata_cont_val_t *container ); + int ( *empty_gdata_container )( lsi_gdata_cont_val_t *container ); /** * @brief purge_gdata_container is used to delete the physical files of the empty container. @@ -1611,7 +1623,7 @@ typedef struct lsi_api_t * @param[in] container - the global data container. * @return -1 on failure, 0 on success. */ - int ( *purge_gdata_container )( struct lsi_gdata_cont_val_t *container ); + int ( *purge_gdata_container )( lsi_gdata_cont_val_t *container ); /** * @brief get_gdata is used to get the global data which was already set to the container. @@ -1630,7 +1642,7 @@ typedef struct lsi_api_t * @return a pointer to the user-defined global data, (as defined in gdata_item_val_t.value) on success, * NULL on failure. */ - void * ( *get_gdata )( struct lsi_gdata_cont_val_t *container, const char *key, int key_len, + void * ( *get_gdata )( lsi_gdata_cont_val_t *container, const char *key, int key_len, lsi_release_callback_pf release_cb, int renew_TTL, lsi_deserialize_pf deserialize_cb); /** @@ -1643,7 +1655,7 @@ typedef struct lsi_api_t * @param[in] key_len - the string length. * @return 0. */ - int ( *delete_gdata )( struct lsi_gdata_cont_val_t *container, const char *key, int key_len ); + int ( *delete_gdata )( lsi_gdata_cont_val_t *container, const char *key, int key_len ); /** * @brief set_gdata is used to set the global data (void * val) with a given key. @@ -1666,7 +1678,7 @@ typedef struct lsi_api_t * @param[in] serialize_cb - a pointer to the user-defined serializer callback function used for file write. * @return -1 on failure, 1 on not forced, 0 on success. */ - int ( *set_gdata )( struct lsi_gdata_cont_val_t *container, const char *key, int key_len, void *val, int TTL, + int ( *set_gdata )( lsi_gdata_cont_val_t *container, const char *key, int key_len, void *val, int TTL, lsi_release_callback_pf release_cb, int force_update, lsi_serialize_pf serialize_cb ); /** @@ -1677,7 +1689,7 @@ typedef struct lsi_api_t * @param[in] session - a pointer to void, ultimately to HttpSession. * @return length of the request header. */ - int ( *get_req_raw_headers_length )( void *session ); + int ( *get_req_raw_headers_length )( lsi_session_t session ); /** * @brief get_req_raw_headers can be used to store all of the request headers in a given buffer. @@ -1691,7 +1703,7 @@ typedef struct lsi_api_t * @param[in] maxlen - the size of the buffer. * @return - the length of the request header. */ - int ( *get_req_raw_headers )( void *session, char *buf, int maxlen ); + int ( *get_req_raw_headers )( lsi_session_t session, char *buf, int maxlen ); /** * @brief get_req_header can be used to get a request header based on the given key. @@ -1704,7 +1716,7 @@ typedef struct lsi_api_t * @param[in,out] valLen - a pointer to the length of the returned string. * @return a pointer to the request header key value string. */ - const char* ( *get_req_header )( void *session, const char *key, int keyLen, int *valLen ); + const char* ( *get_req_header )( lsi_session_t session, const char *key, int keyLen, int *valLen ); /** * @brief get_req_header_by_id can be used to get a request header based on the given header id @@ -1717,7 +1729,7 @@ typedef struct lsi_api_t * @param[in,out] valLen - a pointer to the length of the returned string. * @return a pointer to the request header key value string. */ - const char* ( *get_req_header_by_id )( void *session, int id, int *valLen ); + const char* ( *get_req_header_by_id )( lsi_session_t session, int id, int *valLen ); /** * @brief get_req_org_uri is used to get the original URI as delivered in the request, @@ -1731,7 +1743,7 @@ typedef struct lsi_api_t * * @return length of the URI string. */ - int ( *get_req_org_uri )( void *session, char *buf, int buf_size ); + int ( *get_req_org_uri )( lsi_session_t session, char *buf, int buf_size ); /** @@ -1743,7 +1755,7 @@ typedef struct lsi_api_t * @param[in,out] uri_len - a pointer to int, if not NULL, the length of the URI is returned. * @return pointer to the URI string. The string is readonly. */ - const char* ( *get_req_uri )( void *session, int *uri_len ); + const char* ( *get_req_uri )( lsi_session_t session, int *uri_len ); /** @@ -1755,7 +1767,7 @@ typedef struct lsi_api_t * @param[in,out] length - the length of the returned string. * @return pointer to the context URI string. */ - const char* ( *get_mapped_context_uri )( void *session, int *length ); + const char* ( *get_mapped_context_uri )( lsi_session_t session, int *length ); /** @@ -1770,7 +1782,7 @@ typedef struct lsi_api_t * @param[in] scriptLen - the length of the script name string. * @return -1 on failure, 0 on success. */ - int ( *register_req_handler )( void *session, lsi_module_t *pModule, int scriptLen ); + int ( *register_req_handler )( lsi_session_t session, lsi_module_t *pModule, int scriptLen ); /** @@ -1785,7 +1797,7 @@ typedef struct lsi_api_t * @return * */ - int ( *set_handler_write_state )( void *session, int state ); + int ( *set_handler_write_state )( lsi_session_t session, int state ); /** * @brief set_timer sets a timer. @@ -1819,7 +1831,7 @@ typedef struct lsi_api_t * @param[in,out] len - a pointer to the length of the cookies string. * @return a pointer to the cookie key string. */ - const char * ( *get_req_cookies )( void *session, int *len ); + const char * ( *get_req_cookies )( lsi_session_t session, int *len ); /** * @brief get_req_cookie_count is used to get the request cookies count. @@ -1829,7 +1841,7 @@ typedef struct lsi_api_t * @param[in] session - a pointer to void, ultimately to HttpSession. * @return the number of cookies. */ - int ( *get_req_cookie_count )( void *session ); + int ( *get_req_cookie_count )( lsi_session_t session ); /** * @brief get_cookie_value is to get a cookie based on the cookie name. @@ -1842,7 +1854,7 @@ typedef struct lsi_api_t * @param[in,out] valLen - a pointer to the length of the cookie string. * @return a pointer to the cookie string. */ - const char * ( *get_cookie_value )( void *session, const char * cookie_name, int nameLen, int *valLen ); + const char * ( *get_cookie_value )( lsi_session_t session, const char * cookie_name, int nameLen, int *valLen ); /** * @brief get_client_ip is used to get the request ip address. @@ -1853,7 +1865,7 @@ typedef struct lsi_api_t * @param[in,out] len - a pointer to the length of the IP string. * @return a pointer to the IP string. */ - const char * ( *get_client_ip )( void *session, int *len ); + const char * ( *get_client_ip )( lsi_session_t session, int *len ); /** * @brief get_req_query_string is used to get the request query string. @@ -1864,7 +1876,7 @@ typedef struct lsi_api_t * @param[in,out] len - a pointer to the length of the query string. * @return a pointer to the query string. */ - const char * ( *get_req_query_string )( void *session, int *len ); + const char * ( *get_req_query_string )( lsi_session_t session, int *len ); /** @@ -1880,7 +1892,7 @@ typedef struct lsi_api_t * @param[in] maxValLen - the maximum size of the variable value string. * @return the length of the variable value string. */ - int ( *get_req_var_by_id )( void *session, int id, char *val, int maxValLen ); + int ( *get_req_var_by_id )( lsi_session_t session, int id, char *val, int maxValLen ); /** @@ -1896,7 +1908,7 @@ typedef struct lsi_api_t * @param[in] maxValLen - the maximum size of the variable value string. * @return the length of the variable value string. */ - int ( *get_req_env )( void *session, const char *name, unsigned int nameLen, char *val, int maxValLen ); + int ( *get_req_env )( lsi_session_t session, const char *name, unsigned int nameLen, char *val, int maxValLen ); @@ -1911,7 +1923,7 @@ typedef struct lsi_api_t * @param[in] val - a pointer to the variable value string. * @param[in] valLen - the size of the variable value string. */ - void ( *set_req_env )( void *session, const char *name, unsigned int nameLen, const char *val, int valLen ); + void ( *set_req_env )( lsi_session_t session, const char *name, unsigned int nameLen, const char *val, int valLen ); /** @@ -1940,7 +1952,7 @@ typedef struct lsi_api_t * @param[in] max_len - the max length of the path string. * @return the length of the path string. */ - int ( *get_uri_file_path )( void *session, const char *uri, int uri_len, char *path, int max_len ); + int ( *get_uri_file_path )( lsi_session_t session, const char *uri, int uri_len, char *path, int max_len ); /** * @brief set_uri_qs changes uri and query string of the current session, perform internal/external redirect. @@ -1955,7 +1967,7 @@ typedef struct lsi_api_t * @param[in] qs_len - the length of the Query String. * @return -1 on failure, 0 on success. */ - int ( *set_uri_qs )( void *session, int action, const char *uri, int uri_len, const char *qs, int qs_len ); + int ( *set_uri_qs )( lsi_session_t session, int action, const char *uri, int uri_len, const char *qs, int qs_len ); /** * @brief get_req_content_length is used to get the content length of the request. @@ -1965,7 +1977,7 @@ typedef struct lsi_api_t * @param[in] session - a pointer to void, ultimately to HttpSession. * @return content length. */ - int ( *get_req_content_length )( void *session ); + int ( *get_req_content_length )( lsi_session_t session ); /** * @brief read_req_body is used to get the request body to a given buffer. @@ -1977,7 +1989,7 @@ typedef struct lsi_api_t * @param[in] buflen - size of the buffer. * @return length of the request body. */ - int ( *read_req_body )( void *session, char *buf, int bufLen ); + int ( *read_req_body )( lsi_session_t session, char *buf, int bufLen ); /** @@ -1989,7 +2001,7 @@ typedef struct lsi_api_t * @return * */ - int ( *is_req_body_finished )( void *session ); + int ( *is_req_body_finished )( lsi_session_t session ); /** * @brief set_req_wait_full_body is used to make the server wait to call @@ -2005,7 +2017,7 @@ typedef struct lsi_api_t * @param[in] session - a pointer to void, ultimately to HttpSession. * @return */ - int ( *set_req_wait_full_body )( void *session ); + int ( *set_req_wait_full_body )( lsi_session_t session ); /** * @brief set_resp_wait_full_body is used to make the server wait for the @@ -2023,7 +2035,7 @@ typedef struct lsi_api_t * @param[in] session - a pointer to void, ultimately to HttpSession. * @return */ - int ( *set_resp_wait_full_body )( void *session ); + int ( *set_resp_wait_full_body )( lsi_session_t session ); /** * @brief set_status_code is used to set the response status code of a HTTP session. @@ -2036,7 +2048,7 @@ typedef struct lsi_api_t * @param[in] session - a pointer to void, ultimately to HttpSession. * @param[in] code - the http response status code. */ - void ( *set_status_code )( void *session, int code ); + void ( *set_status_code )( lsi_session_t session, int code ); /** @@ -2047,7 +2059,7 @@ typedef struct lsi_api_t * @param[in] session - a pointer to void, ultimately to HttpSession. * @return the http response status code. */ - int ( *get_status_code )( void *session ); + int ( *get_status_code )( lsi_session_t session ); /** @@ -2059,10 +2071,10 @@ typedef struct lsi_api_t * @param[in] session - a pointer to void, ultimately to HttpSession. * @return -1 on failure, 0 false, 1 true. */ - int ( *is_resp_buffer_available)( void *session ); + int ( *is_resp_buffer_available)( lsi_session_t session ); - int ( *is_resp_buffer_gzippped)( void *session ); + int ( *is_resp_buffer_gzippped)( lsi_session_t session ); /** * @brief append_resp_body is used to append a buffer to the response body. @@ -2077,7 +2089,7 @@ typedef struct lsi_api_t * @param[in] buflen - the size of the buffer. * @return the length of the request body. */ - int ( *append_resp_body )( void *session, const char *buf, int len ); + int ( *append_resp_body )( lsi_session_t session, const char *buf, int len ); /** * @brief append_resp_bodyv is used to append an iovec to the response body. @@ -2092,7 +2104,7 @@ typedef struct lsi_api_t * @param[in] count - the size of the IO vector. * @return -1 on failure, return value of the hook filter callback function. */ - int ( *append_resp_bodyv )( void *session, const struct iovec *iov, int count ); + int ( *append_resp_bodyv )( lsi_session_t session, const struct iovec *iov, int count ); /** * @brief send_file is used to send a file as the response body. @@ -2106,7 +2118,7 @@ typedef struct lsi_api_t * @param[in] size - remaining size. * @return -1 or error codes from various layers of calls on failure, 0 on success. */ - int ( *send_file )( void *session, const char *path, int64_t start, int64_t size ); + int ( *send_file )( lsi_session_t session, const char *path, int64_t start, int64_t size ); /** @@ -2116,7 +2128,7 @@ typedef struct lsi_api_t * * @param[in] session - a pointer to void, ultimately to HttpSession. */ - void ( *flush )( void *session ); + void ( *flush )( lsi_session_t session ); /** * @brief end_resp is called when the response sending is complete. @@ -2125,7 +2137,7 @@ typedef struct lsi_api_t * * @param[in] session - a pointer to void, ultimately to HttpSession. */ - void ( *end_resp )( void *session ); + void ( *end_resp )( lsi_session_t session ); /** * @brief set_resp_content_length sets the Content Length of the response. @@ -2137,7 +2149,7 @@ typedef struct lsi_api_t * @param[in] len - the content length. * @return 0. */ - int ( *set_resp_content_length )( void *session, int64_t len ); + int ( *set_resp_content_length )( lsi_session_t session, int64_t len ); /** * @brief set_resp_header is used to set a response header. @@ -2157,7 +2169,7 @@ typedef struct lsi_api_t * @param[in] add_method - enum defined for the method of adding. * @return 0. */ - int ( *set_resp_header )( void *session, unsigned int header_id, const char *name, int nameLen, const char *val, int valLen, int add_method ); + int ( *set_resp_header )( lsi_session_t session, unsigned int header_id, const char *name, int nameLen, const char *val, int valLen, int add_method ); /** * @brief set_resp_header2 is used to parse the headers first then perform set_resp_header. @@ -2170,7 +2182,7 @@ typedef struct lsi_api_t * @param[in] add_method - enum defined for the method of adding. * @return 0. */ - int ( *set_resp_header2 )( void *session, const char *headers, int len, int add_method ); + int ( *set_resp_header2 )( lsi_session_t session, const char *headers, int len, int add_method ); /** * @brief get_resp_header is used to get a response header's value in an iovec array. @@ -2189,7 +2201,7 @@ typedef struct lsi_api_t * @param[in] maxIovCount - size of the IO vector. * @return the count of headers in the IO vector. */ - int ( *get_resp_header )( void *session, unsigned int header_id, const char *name, int nameLen, struct iovec *iov, int maxIovCount ); + int ( *get_resp_header )( lsi_session_t session, unsigned int header_id, const char *name, int nameLen, struct iovec *iov, int maxIovCount ); /** * @brief get_resp_headers_count is used to get the count of the response headers. @@ -2200,7 +2212,7 @@ typedef struct lsi_api_t * @param[in] session - a pointer to void, ultimately to HttpSession. * @return the number of headers in the whole response header. */ - int ( *get_resp_headers_count )( void *session ); + int ( *get_resp_headers_count )( lsi_session_t session ); /** * @brief get_resp_headers it used to get the whole response headers and store them to the iovec array. @@ -2214,7 +2226,7 @@ typedef struct lsi_api_t * @param[in] maxIovCount - size of the IO vector. * @return the count of all the headers. */ - int ( *get_resp_headers )( void *session, struct iovec *iov, int maxIovCount ); + int ( *get_resp_headers )( lsi_session_t session, struct iovec *iov, int maxIovCount ); /** * @brief remove_resp_header is used to remove a response header. @@ -2230,7 +2242,7 @@ typedef struct lsi_api_t * @param[in] nameLen - the length of the header id name string. * @return 0. */ - int ( *remove_resp_header )( void *session, unsigned int header_id, const char *name, int nameLen ); + int ( *remove_resp_header )( lsi_session_t session, unsigned int header_id, const char *name, int nameLen ); /** @@ -2249,7 +2261,7 @@ typedef struct lsi_api_t * * @return if success, return the size of path, if error, return -1. */ - int ( *get_file_path_by_uri )( void *session, const char * uri, int uri_len, char * path, int max_len ); + int ( *get_file_path_by_uri )( lsi_session_t session, const char * uri, int uri_len, char * path, int max_len ); /** * @brief get_mime_type_by_suffix it used to get corresponding MIME type based on file suffix. @@ -2262,7 +2274,7 @@ typedef struct lsi_api_t * @return return the readonly MIME type string. */ - const char * ( *get_mime_type_by_suffix )( void *session, const char * suffix ); + const char * ( *get_mime_type_by_suffix )( lsi_session_t session, const char * suffix ); /** * @brief set_force_mime_type it used to force server core to use a MIME type with request in current session. @@ -2274,7 +2286,7 @@ typedef struct lsi_api_t * * @return return 0 if success, -1 if failure. */ - int ( *set_force_mime_type )( void * session, const char * mime ); + int ( *set_force_mime_type )( lsi_session_t session, const char * mime ); /** @@ -2287,7 +2299,7 @@ typedef struct lsi_api_t * * @return return the file path string if success, NULL if no static file associated. */ - const char * (*get_req_file_path )( void * session, int * pathLen ); + const char * (*get_req_file_path )( lsi_session_t session, int * pathLen ); /** * @brief get_req_handler_type it used to get the type name of a handler assigned to this request. @@ -2299,7 +2311,7 @@ typedef struct lsi_api_t * @return return type name string, if no handler assigned, return NULL. */ - const char * ( *get_req_handler_type )( void * session ); + const char * ( *get_req_handler_type )( lsi_session_t session ); /** * @brief is_access_log_on it returns if access logging is enabled for this session. @@ -2310,7 +2322,7 @@ typedef struct lsi_api_t * * @return return 1 if access logging is enabled, 0 if access logging is disabled. */ - int ( *is_access_log_on )( void * session ); + int ( *is_access_log_on )( lsi_session_t session ); /** * @brief set_access_log it turns on or off access logging. @@ -2320,7 +2332,7 @@ typedef struct lsi_api_t * @param[in] session - a pointer to void, ultimately to HttpSession. * @param[in] on_off - set to 1 to turn on access logging, set to 0 to turn off access logging. */ - void ( *set_access_log )( void * session, int on_off ); + void ( *set_access_log )( lsi_session_t session, int on_off ); /** * @brief get_access_log_string it turns a string for access log based on the log_pattern. @@ -2334,11 +2346,11 @@ typedef struct lsi_api_t * * @return the length of the final log string, -1 if error. */ - int ( *get_access_log_string )( void * session, const char * log_pattern, char * buf, int bufLen ); + int ( *get_access_log_string )( lsi_session_t session, const char * log_pattern, char * buf, int bufLen ); - int ( *get_file_stat )( void * session, const char *path, int pathLen, struct stat * st ); + int ( *get_file_stat )( lsi_session_t session, const char *path, int pathLen, struct stat * st ); - int ( *is_resp_handler_aborted )( void * session ); + int ( *is_resp_handler_aborted )( lsi_session_t session ); /** * @brief get_resp_body_buf it turns a buffer that holds response body of current session . @@ -2349,7 +2361,7 @@ typedef struct lsi_api_t * * @return the pointer to the response body buffer, NULL if resposne body is not available. */ - void * ( *get_resp_body_buf )( void * session ); + void * ( *get_resp_body_buf )( lsi_session_t session ); /** * @brief get_req_body_buf it turns a buffer that holds request body of current session . @@ -2360,7 +2372,7 @@ typedef struct lsi_api_t * * @return the pointer to the request body buffer, NULL if resposne body is not available. */ - void * ( *get_req_body_buf )( void * session ); + void * ( *get_req_body_buf )( lsi_session_t session ); int64_t ( *get_body_buf_size )( void * pBuf ); @@ -2396,7 +2408,7 @@ typedef struct lsi_api_t * * @param[in] session - a pointer to void, ultimately to HttpSession. */ - void ( *end_resp_headers )( void *session ); + void ( *end_resp_headers )( lsi_session_t session ); /** * @brief get_module_name returns the name of the module. @@ -2450,9 +2462,9 @@ typedef struct lsi_api_t int ( *shm_htable_destory )( lsi_shm_htable_t * ); - int ( *is_subrequest )( void * session ); - + int ( *is_subrequest )( lsi_session_t session ); + time_t ( *get_cur_time )( int32_t * usec ); diff --git a/configure b/configure index 0267acc4f..426d77864 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for openlitespeed 1.3.1. +# Generated by GNU Autoconf 2.69 for openlitespeed 1.3.2. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='openlitespeed' PACKAGE_TARNAME='openlitespeed' -PACKAGE_VERSION='1.3.1' -PACKAGE_STRING='openlitespeed 1.3.1' +PACKAGE_VERSION='1.3.2' +PACKAGE_STRING='openlitespeed 1.3.2' PACKAGE_BUGREPORT='info@litespeedtech.com' PACKAGE_URL='http://www.litespeedtech.com/' @@ -1357,7 +1357,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures openlitespeed 1.3.1 to adapt to many kinds of systems. +\`configure' configures openlitespeed 1.3.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1427,7 +1427,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of openlitespeed 1.3.1:";; + short | recursive ) echo "Configuration of openlitespeed 1.3.2:";; esac cat <<\_ACEOF @@ -1562,7 +1562,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -openlitespeed configure 1.3.1 +openlitespeed configure 1.3.2 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2236,7 +2236,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by openlitespeed $as_me 1.3.1, which was +It was created by openlitespeed $as_me 1.3.2, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3102,7 +3102,7 @@ fi # Define the identity of the package. PACKAGE='openlitespeed' - VERSION='1.3.1' + VERSION='1.3.2' # Some tools Automake needs. @@ -18101,7 +18101,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by openlitespeed $as_me 1.3.1, which was +This file was extended by openlitespeed $as_me 1.3.2, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -18168,7 +18168,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -openlitespeed config.status 1.3.1 +openlitespeed config.status 1.3.2 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index ad5c76412..b86bec4d1 100644 --- a/configure.ac +++ b/configure.ac @@ -5,7 +5,7 @@ m4_include(ax_lib_expat.m4) dnl Process this file with autoconf to produce a configure script. AC_PREREQ([2.69]) -AC_INIT([openlitespeed],[1.3.1],[info@litespeedtech.com],[openlitespeed],[http://www.litespeedtech.com/]) +AC_INIT([openlitespeed],[1.3.2],[info@litespeedtech.com],[openlitespeed],[http://www.litespeedtech.com/]) AM_INIT_AUTOMAKE([1.0 foreign no-define ]) AM_CONFIG_HEADER(src/config.h:src/config.h.in) diff --git a/dist/VERSION b/dist/VERSION index 3a3cd8cc8..1892b9267 100644 --- a/dist/VERSION +++ b/dist/VERSION @@ -1 +1 @@ -1.3.1 +1.3.2 diff --git a/dist/admin/html.open/classes/CValidation.php b/dist/admin/html.open/classes/CValidation.php index dbec5e12e..661984e0f 100644 --- a/dist/admin/html.open/classes/CValidation.php +++ b/dist/admin/html.open/classes/CValidation.php @@ -7,7 +7,7 @@ class CValidation public function __construct() { $this->_info = NULL; } - + public function ExtractPost($tbl, &$d, $disp) { $this->_info = $disp->_info; @@ -16,15 +16,15 @@ public function ExtractPost($tbl, &$d, $disp) foreach ( $index as $i ) { $attr = $tbl->_dattrs[$i]; - if ( $attr == NULL || $attr->bypassSavePost()) + if ( $attr == NULL || $attr->bypassSavePost()) continue; - + $d[$attr->_key] = $attr->extractPost(); $needCheck = TRUE; if ( $attr->_type == 'sel1' || $attr->_type == 'sel2' ) { if ( $disp->_act == 'c' ) { $needCheck = FALSE; - } + } else { $attr->populate_sel1_options($this->_info, $d); } @@ -40,7 +40,7 @@ public function ExtractPost($tbl, &$d, $disp) $this->setValid($goFlag, $res); $this->_info = NULL; - + // if 0 , make it always point to curr page return $goFlag; } @@ -117,9 +117,9 @@ protected function validatePostTbl($tbl, &$d) } } } - - $checkedTids = array('VH_TOP_D','VH_BASE','VH_UDB', 'ADMIN_USR', 'ADMIN_USR_NEW', - 'L_GENERAL', 'L_GENERAL1', 'ADMIN_L_GENERAL', 'ADMIN_L_GENERAL1', 'L_SSL', 'L_CERT', 'L_SSL_CERT', + + $checkedTids = array('VH_TOP_D','VH_BASE','VH_UDB', 'ADMIN_USR', 'ADMIN_USR_NEW', + 'L_GENERAL', 'L_GENERAL1', 'ADMIN_L_GENERAL', 'ADMIN_L_GENERAL1', 'L_SSL', 'L_CERT', 'L_SSL_CERT', 'TP', 'TP1'); if ( in_array($tbl->_id, $checkedTids) ) { @@ -156,47 +156,47 @@ protected function validatePostTbl($tbl, &$d) break; } } - + return $isValid; } - - + + protected function chkPostTbl_TP(&$d) { $isValid = 1; - + $confCenter = ConfCenter::singleton(); - + $oldName = trim($confCenter->GetDispInfo()->_name); $newName = trim($d['name']->GetVal()); - + if($oldName != $newName && array_key_exists($newName, $confCenter->_serv->_data['tpTop'])) { $d['name']->SetErr("Template: \"$newName\" already exists. Please use a different name."); $isValid = -1; - + } - + return $isValid; } - + protected function chkPostTbl_VH_BASE(&$d) { $isValid = 1; - + $confCenter = ConfCenter::singleton(); - + $oldName = trim($confCenter->GetDispInfo()->_name); $newName = trim($d['name']->GetVal()); - + if($oldName != $newName && array_key_exists($newName, $confCenter->_serv->_data['vhTop'])) { $d['name']->SetErr("Virtual Hostname: \"$newName\" already exists. Please use a different name."); $isValid = -1; - + } - + return $isValid; } - + protected function chkPostTbl_VH_UDB(&$d) { $isValid = 1; @@ -224,20 +224,20 @@ protected function chkPostTbl_VH_UDB(&$d) protected function encryptPass($val) { $valid_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/."; - if (CRYPT_MD5 == 1) - { + $limit = strlen($valid_chars)-1; + $isMac = (strtoupper(PHP_OS) === 'DARWIN'); + + if (CRYPT_MD5 == 1 && !$isMac) { $salt = '$1$'; - for($i = 0; $i < 8; $i++) - { - $salt .= $valid_chars[rand(0,strlen($valid_chars)-1)]; + for($i = 0; $i < 8; $i++) { + $salt .= $valid_chars[rand(0,$limit)]; } $salt .= '$'; } - else - { - $salt = $valid_chars[rand(0,strlen($valid_chars)-1)]; - $salt .= $valid_chars[rand(0,strlen($valid_chars)-1)]; - } + else { + $salt = $valid_chars[rand(0,$limit)]; + $salt .= $valid_chars[rand(0,$limit)]; + } $pass = crypt($val, $salt); return $pass; } @@ -305,16 +305,16 @@ protected function chkPostTbl_ADMIN_USR_NEW(&$d) protected function chkPostTbl_L_GENERAL(&$d) { $isValid = 1; - + $ip = $d['ip']->GetVal(); if ( $ip == 'ANY' ) { $ip = '*'; } $port = $d['port']->GetVal(); $d['address'] = new CVal("$ip:$port"); - + $confCenter = ConfCenter::singleton(); - + $oldName = trim($confCenter->GetDispInfo()->_name); $newName = trim($d['name']->GetVal()); @@ -322,10 +322,10 @@ protected function chkPostTbl_L_GENERAL(&$d) $d['name']->SetErr("Listener \"$newName\" already exists. Please use a different name."); $isValid = -1; } - + return $isValid; } - + protected function isCurrentListenerSecure() { $confCenter = ConfCenter::singleton(); @@ -333,7 +333,7 @@ protected function isCurrentListenerSecure() $l = $confCenter->_serv->_data['listeners'][$listenerName]; return ($l['secure']->GetVal() == 1); } - + protected function chkPostTbl_L_SSL(&$d) { $isValid = 1; @@ -348,7 +348,7 @@ protected function chkPostTbl_L_SSL(&$d) $isValid = -1; } } - + return $isValid; } @@ -366,10 +366,10 @@ protected function chkPostTbl_L_SSL_CERT(&$d) $isValid = -1; } } - + return $isValid; } - + protected function validateTblAttr($tblDef, $tbl, &$data) { $valid = 1; @@ -415,7 +415,7 @@ protected function isValidAttr($attr, $cval) { if ($cval == NULL || $cval->HasErr()) return -1; - + if ( !$cval->HasVal()) { if ( $attr->_allowNull ) { return 1; @@ -427,11 +427,11 @@ protected function isValidAttr($attr, $cval) if ( $attr->_type == 'cust' ) { return 1; } - + $chktype = array('uint', 'name', 'vhname', 'sel','sel1','sel2', 'bool','file','filep','file0','file1', 'filetp', 'path', 'uri','expuri','url', 'httpurl', 'email', 'dir', 'addr', 'parse'); - + if ( !in_array($attr->_type, $chktype) ) { // not checked type ('domain', 'subnet' return 1; @@ -475,14 +475,14 @@ protected function chkAttr_sel($attr, $cval) protected function chkAttr_sel_val($attr, $val, &$err) { - if ( isset( $attr->_maxVal ) + if ( isset( $attr->_maxVal ) && !array_key_exists($val, $attr->_maxVal) ) { $err = "invalid value: $val"; return -1; } return 1; } - + protected function chkAttr_name($attr, $cval) { $cval->SetVal( preg_replace("/\s+/", ' ', $cval->GetVal())); @@ -503,7 +503,7 @@ protected function chkAttr_name_val($attr, $val, &$err) } return 1; } - + protected function chkAttr_vhname($attr, $cval) { $cval->SetVal(preg_replace("/\s+/", ' ', $cval->GetVal())); @@ -612,12 +612,12 @@ protected function chkAttr_file($attr, $cval) $cval->SetErr($err); return $res; } - + protected function chkAttr_dir($attr, $cval) { $val = $cval->GetVal(); $err = ''; - + if ( substr($val,-1) == '*' ) { $res = $this->chkAttr_file_val($attr, substr($val,0,-1), $err); } else { @@ -630,7 +630,7 @@ protected function chkAttr_dir($attr, $cval) public function chkAttr_file_val($attr, $val, &$err) { - //this is public + //this is public clearstatcache(); $err = NULL; @@ -693,9 +693,9 @@ protected function chk_file1($attr, &$path, &$err) $err = "Invalid Path."; return -1; } - + $s = $path{0}; - + if ( strpos($path, '$VH_NAME') !== FALSE ) { $path = str_replace('$VH_NAME', $this->_info['VH_NAME'], $path); } @@ -785,7 +785,7 @@ protected function chkAttr_httpurl($attr, $cval) } return 1; } - + protected function chkAttr_email($attr, $cval) { $err = ''; @@ -793,7 +793,7 @@ protected function chkAttr_email($attr, $cval) $cval->SetErr($err); return $res; } - + protected function chkAttr_email_val($attr, $val, &$err) { if ( preg_match("/^[[:alnum:]._-]+@.+/", $val ) ) { @@ -803,7 +803,7 @@ protected function chkAttr_email_val($attr, $val, &$err) return -1; } } - + protected function chkAttr_addr($attr, $cval) { if ( preg_match("/^[[:alnum:]._-]+:(\d)+$/", $cval->GetVal()) ) { @@ -833,7 +833,7 @@ protected function chkAttr_parse($attr, $cval) $cval->SetErr($err); return $res; } - + protected function chkAttr_parse_val($attr, $val, &$err) { if ( preg_match($attr->_minVal, $val) ) { diff --git a/dist/admin/misc/htpasswd.php b/dist/admin/misc/htpasswd.php index 40efe1ef8..18a46faf5 100644 --- a/dist/admin/misc/htpasswd.php +++ b/dist/admin/misc/htpasswd.php @@ -1,19 +1,20 @@ getState() & (HEC_ABORT_REQUEST|HEC_ERROR|HEC_COMPLETE|HEC_REDIRECT))) ) - ret = getConnector()->processRespBodyData( 0, (const char *)p, len ); + ret = getConnector()->processRespBodyData( (const char *)p, len ); p += len; m_chunkLeft -= len; } diff --git a/src/extensions/lsapi/lsapiconn.cpp b/src/extensions/lsapi/lsapiconn.cpp index 0d630450c..74f7c0cc3 100644 --- a/src/extensions/lsapi/lsapiconn.cpp +++ b/src/extensions/lsapi/lsapiconn.cpp @@ -835,7 +835,7 @@ int LsapiConn::readRespBody() } else { - len = pHEC->processRespBodyData( 1, pBuf, packetLen ); + len = pHEC->processRespBodyData( pBuf, packetLen ); } if ( m_iPacketLeft <= 0 ) { diff --git a/src/extensions/proxy/proxyconn.cpp b/src/extensions/proxy/proxyconn.cpp index 1d31b41cf..c70b1eb40 100644 --- a/src/extensions/proxy/proxyconn.cpp +++ b/src/extensions/proxy/proxyconn.cpp @@ -491,7 +491,7 @@ int ProxyConn::readRespBody() { m_lLastRespRecvTime = time( NULL ); m_iRespBodyRecv += ret; - int ret1 = pHEC->processRespBodyData( 1, pBuf, ret ); + int ret1 = pHEC->processRespBodyData( pBuf, ret ); if ( ret1 ) return ret1; if ( ret > 1024 ) @@ -533,7 +533,7 @@ int ProxyConn::readRespBody() if ( ret > 0 ) { m_iRespBodyRecv += ret; - pHEC->processRespBodyData( 1, pBuf, ret ); + pHEC->processRespBodyData( pBuf, ret ); if ( ret > 1024 ) pHEC->flushResp(); //if ( ret1 ) diff --git a/src/http/httpextconnector.cpp b/src/http/httpextconnector.cpp index fd24365c7..a1ae08550 100644 --- a/src/http/httpextconnector.cpp +++ b/src/http/httpextconnector.cpp @@ -204,11 +204,6 @@ int HttpExtConnector::respHeaderDone() return ret; } - - -#define MIN_GZIP_SIZE 200 - - int HttpExtConnector::processRespData( const char * pBuf, int len ) { @@ -221,7 +216,7 @@ int HttpExtConnector::processRespData( const char * pBuf, int len ) return ret; } if ( len > 0 ) - return processRespBodyData( 0, pBuf, len ); + return processRespBodyData( pBuf, len ); else return 0; } @@ -248,13 +243,11 @@ int HttpExtConnector::flushResp() } -int HttpExtConnector::processRespBodyData( int inplace, const char * pBuf, int len ) +int HttpExtConnector::processRespBodyData( const char * pBuf, int len ) { if ( D_ENABLED( DL_MEDIUM ) ) LOG_D((getLogger(), "[%s] HttpExtConnector::processRespBodyData()", getLogId() )); - if ( inplace && ( pBuf == HttpGlobals::g_achBuf )) - inplace = 0; int ret = m_pSession->appendDynBody( pBuf, len ); if ( ret == -1 ) { diff --git a/src/http/httpextconnector.h b/src/http/httpextconnector.h index be0683475..5aaf62301 100644 --- a/src/http/httpextconnector.h +++ b/src/http/httpextconnector.h @@ -124,7 +124,7 @@ class HttpExtConnector : public ReqHandler, public ExtRequest virtual int dumpAborted(); int parseHeader( const char * &pBuf, int &len, int httpResp=0 ); - int processRespBodyData( int inplace, const char * pBuf, int len ); + int processRespBodyData( const char * pBuf, int len ); int respHeaderDone(); diff --git a/src/http/httpsession.cpp b/src/http/httpsession.cpp index 71b17accf..cc5199134 100644 --- a/src/http/httpsession.cpp +++ b/src/http/httpsession.cpp @@ -1174,7 +1174,7 @@ int HttpSession::processURI( int resume ) { int ret1; ret1 = checkAuthentication( aaa.m_pHTAuth, aaa.m_pRequired, resume); -// if ( ret1 ) + if ( ret1 ) { if ( D_ENABLED( DL_LESS ) ) LOG_D(( getLogger(), "[%s] checkAuthentication() return %d", @@ -1518,7 +1518,7 @@ void HttpSession::sendHttpError( const char * pAdditional ) if (( ret != m_request.getStatusCode() )&&(m_request.getStatusCode() == SC_404) &&( ret != SC_503 )&&( ret > 0 )) { - ( ret, NULL ); + httpError( ret, NULL ); return; } } @@ -2230,7 +2230,7 @@ int HttpSession::setupRespCache() return 0; } -extern int addModgzipFilter(void *session, int isSend, uint8_t compressLevel, int priority); +extern int addModgzipFilter(lsi_session_t session, int isSend, uint8_t compressLevel, int priority); int HttpSession::setupGzipFilter() { register char gz = m_request.gzipAcceptable(); @@ -2556,17 +2556,6 @@ int HttpSession::checkRespSize( int nobuffer ) } flush(); - //if ( !isRespHeaderSent() ) - //{ - // if ( beginWrite() == -1 ) - // ret = -1; - //} - //else - //{ - // setState( HSS_WRITING ); - // //sendResp(); - // continueWrite(); - //} } } return ret; @@ -2664,15 +2653,6 @@ int HttpSession::endResponse( int success ) m_response.setContentLen( size ); -// if ( beginWrite() == -1 ) -// ret = -1; -// } -// else -// { -// //sendResp(); -// setState( HSS_WRITING ); -// continueWrite(); -// } } setFlag(HSF_RESP_FLUSHED, 0); @@ -2822,12 +2802,10 @@ void HttpSession::addLocationHeader( ) headers.appendLastVal( pLocation, m_request.getLocationLen() ); } -void HttpSession::prepareHeaders( int addAcceptRange ) +void HttpSession::prepareHeaders() { HttpRespHeaders &headers = m_response.getRespHeaders(); headers.addCommonHeaders(); - if (addAcceptRange) - headers.appendAcceptRange(); if ( m_request.getAuthRequired() ) m_request.addWWWAuthHeader( headers ); @@ -2869,7 +2847,7 @@ int HttpSession::sendRespHeaders() setupChunkOS( 0 ); } } - prepareHeaders( 0 ); + prepareHeaders(); if ( finalizeHeader( m_request.getVersion(), m_request.getStatusCode()) ) return 1; @@ -3147,7 +3125,9 @@ int HttpSession::sendStaticFileEx( SendFileInfo * pData ) #if !defined( NO_SENDFILE ) int fd = pData->getECache()->getfd(); if ( HttpServerConfig::getInstance().getUseSendfile() && - fd != -1 && !isSSL() ) + pData->getECache()->getfd() != -1 && !isSSL() + && (!getGzipBuf()|| + ( pData->getECache() == pData->getFileData()->getGziped() ) ) ) { len = writeRespBodySendFile( fd, pData->getCurPos(), pData->getRemain() ); if ( len > 0 ) @@ -3167,7 +3147,14 @@ int HttpSession::sendStaticFileEx( SendFileInfo * pData ) { return -1; } - len = writeRespBodyDirect( pBuf, written ); + if ( getGzipBuf() ) + { + len = appendDynBodyEx( pBuf, written ); + if ( !len ) + len = written; + } + else + len = writeRespBodyDirect( pBuf, written ); if ( len > 0 ) { pData->incCurPos( len ); diff --git a/src/http/httpsession.h b/src/http/httpsession.h index 4e81b3815..55d4180a7 100644 --- a/src/http/httpsession.h +++ b/src/http/httpsession.h @@ -366,7 +366,7 @@ class HttpSession : public LsiSession, public HioStreamHandler LsiApiHooks * getModSessionHooks( int index ) { return m_sessionHooks.getCopy( index ); } void setSendFileBeginEnd( off_t start, off_t end ); - void prepareHeaders( int arg1 ); + void prepareHeaders(); void addLocationHeader(); void setAccessLogOff() { m_iFlag |= HSF_ACCESS_LOG_OFF; } diff --git a/src/http/httpstatuscode.cpp b/src/http/httpstatuscode.cpp index 8d33ac141..bfdf2656b 100644 --- a/src/http/httpstatuscode.cpp +++ b/src/http/httpstatuscode.cpp @@ -38,7 +38,7 @@ StatusCode::StatusCode( int code, const char * pStatus, char * pEnd = p + 4096; p += safe_snprintf( p, pEnd - p, "\n" - "%\n%s\n" + "\n%s\n" "\n" "

" diff --git a/src/http/httpvhost.cpp b/src/http/httpvhost.cpp index c7975cfd5..646265831 100644 --- a/src/http/httpvhost.cpp +++ b/src/http/httpvhost.cpp @@ -1807,7 +1807,7 @@ lsi_module_config_t *parseModuleConfigParam(lsi_module_t *pModule, const HttpCon if (config->own_data_flag == 1) { assert(config->sparam != NULL); - config->config = pModule->_config_parser->_parse_config(config->sparam->c_str(), init_config); + config->config = pModule->_config_parser->_parse_config(config->sparam->c_str(), init_config, LSI_CONTEXT_LEVEL, pContext->getURI()); delete config->sparam; config->sparam = NULL; config->own_data_flag = 2; @@ -2080,7 +2080,7 @@ int HttpVHost::config( const XmlNode *pVhConfNode) ModuleConfig *pConfig = new ModuleConfig; pConfig->init(ModuleManager::getInstance().getModuleCount()); pConfig->inherit(ModuleManager::getGlobalModuleConfig()); - ModuleConfig::parseConfigList(pModuleList, pConfig); + ModuleConfig::parseConfigList(pModuleList, pConfig, LSI_VHOST_LEVEL, this->getName()); pRootContext->setModuleConfig(pConfig, 1); } else diff --git a/src/http/staticfilehandler.cpp b/src/http/staticfilehandler.cpp index cb9d4ff97..7925343f5 100644 --- a/src/http/staticfilehandler.cpp +++ b/src/http/staticfilehandler.cpp @@ -79,6 +79,8 @@ inline int buildStaticFileHeaders( HttpResp * pResp, HttpReq * pReq, SendFileInf pData->getFileData()->getHeaderLen() ); pResp->parseAdd( pData->getECache()->getCLHeader().c_str(), pData->getECache()->getCLHeader().len() ); + pResp->getRespHeaders().appendAcceptRange(); + return 0; } diff --git a/src/lsiapi/envmanager.cpp b/src/lsiapi/envmanager.cpp index 9a8e60c0e..d24fb20b9 100644 --- a/src/lsiapi/envmanager.cpp +++ b/src/lsiapi/envmanager.cpp @@ -78,7 +78,7 @@ int EnvManager::execEnvHandler(LsiSession *session, lsi_callback_pf cb, void *va { lsi_cb_param_t param; memset(¶m, 0, sizeof(lsi_cb_param_t)); - param._session = (void *)session; + param._session = session; param._param = val; param._param_len = valLen; return cb(¶m); diff --git a/src/lsiapi/internal.h b/src/lsiapi/internal.h index 339e477df..058fde26e 100644 --- a/src/lsiapi/internal.h +++ b/src/lsiapi/internal.h @@ -3,6 +3,8 @@ #ifndef LSAPI_INTERNAL_H #define LSAPI_INTERNAL_H + +class lsi_session_s; class ModuleConfig; class LogTracker; @@ -47,8 +49,13 @@ typedef struct lsi_module_internal_t //# error not enough space reserved for internal data in struct lsi_module_t //#endif +struct lsi_session_s +{ +}; + +typedef struct lsi_session_s * lsi_session_t; -class LsiSession +class LsiSession : public lsi_session_s { public: LsiSession(){}; diff --git a/src/lsiapi/lsiapi.h b/src/lsiapi/lsiapi.h index 509effd02..0aca484f4 100644 --- a/src/lsiapi/lsiapi.h +++ b/src/lsiapi/lsiapi.h @@ -29,13 +29,13 @@ class LsiModuleData ; -typedef struct gdata_key_t +typedef struct gdata_key_s { char* key_str; int key_str_len; } gdata_key_t; -typedef struct gdata_item_val_t +typedef struct gdata_item_val_s { gdata_key_t key; //Need to deep copy the original buffer void *value; @@ -47,7 +47,7 @@ typedef struct gdata_item_val_t typedef THash __LsiGDataItemHashT; -typedef struct lsi_gdata_cont_val_t { +typedef struct lsi_gdata_cont_val_s { gdata_key_t key; //Need to deep copy the original buffer __LsiGDataItemHashT *container; time_t tmCreate; diff --git a/src/lsiapi/lsiapigd.cpp b/src/lsiapi/lsiapigd.cpp index 6c85ef2a3..4eb31c2bc 100644 --- a/src/lsiapi/lsiapigd.cpp +++ b/src/lsiapi/lsiapigd.cpp @@ -123,7 +123,7 @@ __LsiGDataItemHashT::iterator get_gdata_iterator(__LsiGDataItemHashT *container, //renew_gdata_TTL will not update teh acc time and teh Acc time should be updated when accessing. static void renew_gdata_TTL(__LsiGDataItemHashT::iterator iter, int TTL, int type, const char *file_path) { - struct gdata_item_val_t* pItem = iter.second(); + gdata_item_val_t* pItem = iter.second(); pItem->tmCreate = DateTime::s_curTime; pItem->tmExpire = TTL + pItem->tmCreate; @@ -144,7 +144,7 @@ static void renew_gdata_TTL(__LsiGDataItemHashT::iterator iter, int TTL, int typ void erase_gdata_element(lsi_gdata_cont_val_t* containerInfo, __LsiGDataItemHashT::iterator iter) { - struct gdata_item_val_t* pItem = iter.second(); + gdata_item_val_t* pItem = iter.second(); if (containerInfo->type == LSI_CONTAINER_FILE) { char file_path[LSI_MAX_FILE_PATH_LEN] = {0}; @@ -263,7 +263,7 @@ LSIAPI void * get_gdata(lsi_gdata_cont_val_t *containerInfo, const char *key, in { __LsiGDataItemHashT *pCont = containerInfo->container; __LsiGDataItemHashT::iterator iter = get_gdata_iterator(pCont, key, key_len); - struct gdata_item_val_t* pItem = NULL; + gdata_item_val_t* pItem = NULL; int TTL = 0; time_t tm = DateTime::s_curTime; char file_path[LSI_MAX_FILE_PATH_LEN] = {0}; diff --git a/src/lsiapi/lsiapihooks.cpp b/src/lsiapi/lsiapihooks.cpp index f390e6ba3..b35cc5f99 100644 --- a/src/lsiapi/lsiapihooks.cpp +++ b/src/lsiapi/lsiapihooks.cpp @@ -202,7 +202,7 @@ LsiApiHook * LsiApiHooks::find( const lsi_module_t *pModule ) const LsiApiHook * pHook; for( pHook = begin(); pHook < end(); ++pHook ) { - if( ( pHook->_module == pModule ) ) + if( pHook->_module == pModule ) return pHook; } return NULL; @@ -217,7 +217,7 @@ int LsiApiHooks::remove( const lsi_module_t *pModule ) LsiApiHook * pHook; for( pHook = begin(); pHook < end(); ++pHook ) { - if( ( pHook->_module == pModule ) ) + if( pHook->_module == pModule ) remove( pHook ); } @@ -225,7 +225,7 @@ int LsiApiHooks::remove( const lsi_module_t *pModule ) } //need to check Hook count before call this function -int LsiApiHooks::runCallback(int level, struct lsi_cb_param_t *param) const +int LsiApiHooks::runCallback(int level, lsi_cb_param_t *param) const { int ret = 0; lsi_cb_param_t rec1; diff --git a/src/lsiapi/lsiapihooks.h b/src/lsiapi/lsiapihooks.h index 1ddb04a2c..46493e0d0 100644 --- a/src/lsiapi/lsiapihooks.h +++ b/src/lsiapi/lsiapihooks.h @@ -2,6 +2,7 @@ #define LSIAPIHOOKS_H //#include "lsiapi/modulemanager.h" +#include "lsiapi/internal.h" #include "lsiapi/lsiapi.h" #include "lsiapi/lsimoduledata.h" #include @@ -31,7 +32,7 @@ typedef SessionHooks HttpSessionHooks; typedef SessionHooks<0, LSI_HKPT_L4_COUNT> IolinkSessionHooks; class LsiApiHooks; -typedef struct lsi_hook_info_t +typedef struct lsi_hook_info_s { const LsiApiHooks * _hooks; void * _termination_fp; @@ -85,11 +86,11 @@ class LsiApiHooks int copy( const LsiApiHooks& other ); - int runCallback( int level, struct lsi_cb_param_t *param) const; + int runCallback( int level, lsi_cb_param_t *param) const; int runCallback( int level, LsiSession *session, void *param1, int paramLen1, int *flag_out, int flag_in) const { lsi_hook_info_t info = { this, NULL } ; - struct lsi_cb_param_t param = + lsi_cb_param_t param = { session, &info, begin(), param1, paramLen1, flag_out, flag_in }; return runCallback(level, ¶m); } @@ -268,7 +269,7 @@ class SessionHooks } - int runCallback( int level, struct lsi_cb_param_t *param) const + int runCallback( int level, lsi_cb_param_t *param) const { return get( level )->runCallback( level, param ); } int runCallback( int level, LsiSession *session, void *param1, int paramLen1, int *param2, int paramLen2) const diff --git a/src/lsiapi/lsiapilib.cpp b/src/lsiapi/lsiapilib.cpp index d0c3e455c..4829860a5 100644 --- a/src/lsiapi/lsiapilib.cpp +++ b/src/lsiapi/lsiapilib.cpp @@ -88,7 +88,7 @@ static int lsiapi_add_hook( int index, const lsi_module_t *pModule, lsi_callback return pHooks->add( pModule, cb, order, flag ); } -static int lsiapi_add_session_hook( void * session, int index, const lsi_module_t *pModule, +static int lsiapi_add_session_hook( lsi_session_t session, int index, const lsi_module_t *pModule, lsi_callback_pf cb, short order, short flag ) { const int *priority = MODULE_PRIORITY(pModule); @@ -129,7 +129,7 @@ static int lsiapi_add_session_hook( void * session, int index, const lsi_module_ return pHooks->add( pModule, cb, order, flag ); } -static int lsiapi_remove_session_hook( void * session, int index, const lsi_module_t *pModule ) +static int lsiapi_remove_session_hook( lsi_session_t session, int index, const lsi_module_t *pModule ) { LsiApiHooks * pHooks; switch( index ) @@ -167,7 +167,7 @@ static int lsiapi_remove_session_hook( void * session, int index, const lsi_modu return pHooks->remove( pModule ); } -static void session_log( void *session, int level, const char * fmt, ... ) +static void session_log( lsi_session_t session, int level, const char * fmt, ... ) { char achFmt[4096]; HttpSession * pSess = (HttpSession *)((LsiSession *)session); @@ -190,7 +190,7 @@ static void session_log( void *session, int level, const char * fmt, ... ) } -static void session_vlog( void *session, int level, const char * fmt, va_list vararg, int no_linefeed ) +static void session_vlog( lsi_session_t session, int level, const char * fmt, va_list vararg, int no_linefeed ) { char achFmt[4096]; HttpSession * pSess = (HttpSession *)((LsiSession *)session); @@ -210,7 +210,7 @@ static void session_vlog( void *session, int level, const char * fmt, va_list v } -static void session_lograw( void *session, const char * buf, int len ) +static void session_lograw( lsi_session_t session, const char * buf, int len ) { HttpSession * pSess = (HttpSession *)((LsiSession *)session); LOG4CXX_NS::Logger * pLogger = NULL; @@ -295,7 +295,7 @@ static LsiModuleData * get_module_data_by_type( void* obj, int type ) } -static int set_module_data ( void * session, const lsi_module_t *pModule, int level, void *data ) +static int set_module_data ( lsi_session_t session, const lsi_module_t *pModule, int level, void *data ) { if (level < LSI_MODULE_DATA_HTTP || level > LSI_MODULE_DATA_L4) return -1; @@ -322,7 +322,7 @@ static int set_module_data ( void * session, const lsi_module_t *pModule, int le return ret; } -static void * get_module_data( void * session, const lsi_module_t *pModule, int level ) +static void * get_module_data( lsi_session_t session, const lsi_module_t *pModule, int level ) { LsiModuleData * pData = get_module_data_by_type( session, level ); if ( !pData ) @@ -340,7 +340,7 @@ static void * get_cb_module_data( const lsi_cb_param_t * param, int level ) } -static void free_module_data(void * session, const lsi_module_t *pModule, int level, lsi_release_callback_pf cb) +static void free_module_data(lsi_session_t session, const lsi_module_t *pModule, int level, lsi_release_callback_pf cb) { LsiModuleData * pData = get_module_data_by_type( session, level ); if ( !pData ) @@ -415,7 +415,7 @@ static int lsiapi_stream_writev_next( lsi_cb_param_t * pParam, struct iovec *iov /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -static int get_uri_file_path( void *session, const char *uri, int uri_len, char *path, int max_len ) +static int get_uri_file_path( lsi_session_t session, const char *uri, int uri_len, char *path, int max_len ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -443,7 +443,7 @@ static int get_uri_file_path( void *session, const char *uri, int uri_len, char return 0; } -static int set_resp_content_length( void *session, int64_t len ) +static int set_resp_content_length( lsi_session_t session, int64_t len ) { HttpResp* pResp = ( (HttpSession *)((LsiSession *)session) )->getResp(); pResp->setContentLen(len); @@ -451,7 +451,7 @@ static int set_resp_content_length( void *session, int64_t len ) return 0; } -static int get_status_code( void *session ) +static int get_status_code( lsi_session_t session ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -460,7 +460,7 @@ static int get_status_code( void *session ) return HttpStatusCode::indexToCode(pReq->getStatusCode()); } -static void set_status_code( void *session, int code) +static void set_status_code( lsi_session_t session, int code) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -471,7 +471,7 @@ static void set_status_code( void *session, int code) pReq->updateNoRespBodyByStatus(index); } -static int set_resp_header( void *session, unsigned int header_index, const char *name, int nameLen, const char *val, int valLen, int add_method ) +static int set_resp_header( lsi_session_t session, unsigned int header_index, const char *name, int nameLen, const char *val, int valLen, int add_method ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -491,7 +491,7 @@ static int set_resp_header( void *session, unsigned int header_index, const char } //multi headers supportted. -static int set_resp_header2( void *session, const char *s, int len, int add_method ) +static int set_resp_header2( lsi_session_t session, const char *s, int len, int add_method ) { int len0, len1; HttpSession *pSession = (HttpSession *)((LsiSession *)session); @@ -512,7 +512,7 @@ static int set_resp_header2( void *session, const char *s, int len, int add_meth return 0; } -static int get_resp_header(void *session, unsigned int header_index, const char *name, int nameLen, struct iovec *iov, int maxIovCount ) +static int get_resp_header(lsi_session_t session, unsigned int header_index, const char *name, int nameLen, struct iovec *iov, int maxIovCount ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -526,7 +526,7 @@ static int get_resp_header(void *session, unsigned int header_index, const char //"status" and "version" will also be treated as header in SPDY if it already be put in //and it will be counted. -static int get_resp_headers_count( void *session ) +static int get_resp_headers_count( lsi_session_t session ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -535,7 +535,7 @@ static int get_resp_headers_count( void *session ) return respHeaders.getHeadersCount(0); //For API, retuen the non-spdy case } -static int get_resp_headers( void *session, struct iovec *iov, int maxIovCount ) +static int get_resp_headers( lsi_session_t session, struct iovec *iov, int maxIovCount ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -544,7 +544,7 @@ static int get_resp_headers( void *session, struct iovec *iov, int maxIovCount ) return respHeaders.getAllHeaders( iov, maxIovCount ); } -static int remove_resp_header( void *session, unsigned int header_index, const char *name, int nameLen ) +static int remove_resp_header( lsi_session_t session, unsigned int header_index, const char *name, int nameLen ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -558,7 +558,7 @@ static int remove_resp_header( void *session, unsigned int header_index, const c } -static int get_req_raw_headers_length( void *session) +static int get_req_raw_headers_length( lsi_session_t session) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -567,7 +567,7 @@ static int get_req_raw_headers_length( void *session) return pReq->getHttpHeaderLen(); } -static int get_req_raw_headers( void *session, char *buf, int maxlen) +static int get_req_raw_headers( lsi_session_t session, char *buf, int maxlen) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -581,7 +581,7 @@ static int get_req_raw_headers( void *session, char *buf, int maxlen) return size; } -static int get_req_org_uri( void *session, char *buf, int buf_size ) +static int get_req_org_uri( lsi_session_t session, char *buf, int buf_size ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -597,7 +597,7 @@ static int get_req_org_uri( void *session, char *buf, int buf_size ) return orgLen; } -static const char *get_req_uri( void *session, int * uri_len) +static const char *get_req_uri( lsi_session_t session, int * uri_len) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -608,7 +608,7 @@ static const char *get_req_uri( void *session, int * uri_len) return pReq->getURI(); } -static const char* get_mapped_context_uri( void *session, int *length ) +static const char* get_mapped_context_uri( lsi_session_t session, int *length ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -619,7 +619,7 @@ static const char* get_mapped_context_uri( void *session, int *length ) return pReq->getContext()->getURI(); } -static int register_req_handler( void *session, lsi_module_t *pModule, int scriptLen ) +static int register_req_handler( lsi_session_t session, lsi_module_t *pModule, int scriptLen ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -638,7 +638,7 @@ static int register_req_handler( void *session, lsi_module_t *pModule, int scrip return -1; } -static int set_handler_write_state( void *session, int state ) +static int set_handler_write_state( lsi_session_t session, int state ) { HttpSession* pSession = (HttpSession *)((LsiSession *)session); if (state) @@ -708,7 +708,7 @@ static int lsi_remove_timer( int timer_id ) } -static const char* get_req_header( void *session, const char *key, int keyLen, int *valLen ) +static const char* get_req_header( lsi_session_t session, const char *key, int keyLen, int *valLen ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -724,7 +724,7 @@ static const char* get_req_header( void *session, const char *key, int keyLen, i return pReq->getHeader( key, keyLen, *valLen ); } -static const char* get_req_header_by_id( void *session, int idx, int *valLen ) +static const char* get_req_header_by_id( lsi_session_t session, int idx, int *valLen ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -738,7 +738,7 @@ static const char* get_req_header_by_id( void *session, int idx, int *valLen ) return NULL; } -static const char * get_req_cookies( void *session, int *len ) +static const char * get_req_cookies( lsi_session_t session, int *len ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -746,7 +746,7 @@ static const char * get_req_cookies( void *session, int *len ) return get_req_header( session, "Cookie", 6, len); } -static const char *get_client_ip( void *session, int *len ) +static const char *get_client_ip( lsi_session_t session, int *len ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -755,7 +755,7 @@ static const char *get_client_ip( void *session, int *len ) return pSession->getPeerAddrString(); } -static const char *get_req_query_string( void *session, int *len ) +static const char *get_req_query_string( lsi_session_t session, int *len ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -766,7 +766,7 @@ static const char *get_req_query_string( void *session, int *len ) return pReq->getQueryString(); } -static int get_req_cookie_count( void *session) +static int get_req_cookie_count( lsi_session_t session) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -775,7 +775,7 @@ static int get_req_cookie_count( void *session) return RequestVars::getCookieCount( pReq ); } -static const char * get_cookie_value( void *session, const char * cookie_name, int nameLen, int *valLen ) +static const char * get_cookie_value( lsi_session_t session, const char * cookie_name, int nameLen, int *valLen ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL || !cookie_name || nameLen <= 0 ) @@ -784,7 +784,7 @@ static const char * get_cookie_value( void *session, const char * cookie_name, i return RequestVars::getCookieValue( pReq, cookie_name, nameLen, *valLen ); } -// static int get_req_body_file_fd( void *session ) +// static int get_req_body_file_fd( lsi_session_t session ) // { // HttpSession *pSession = (HttpSession *)((LsiSession *)session); // if (pSession == NULL ) @@ -887,7 +887,7 @@ int getVarNameStr( const char *name, unsigned int len ) return ret; } -static int get_req_var_by_id( void *session, int type, char *val, int maxValLen ) +static int get_req_var_by_id( lsi_session_t session, int type, char *val, int maxValLen ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -912,7 +912,7 @@ static int get_req_var_by_id( void *session, int type, char *val, int maxValLen return ret; } -static int get_req_env( void *session, const char *name, unsigned int nameLen, char *val, int maxValLen ) +static int get_req_env( lsi_session_t session, const char *name, unsigned int nameLen, char *val, int maxValLen ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -944,7 +944,7 @@ static int get_req_env( void *session, const char *name, unsigned int nameLen, } } -static void set_req_env( void *session, const char *name, unsigned int nameLen, const char *val, int valLen ) +static void set_req_env( lsi_session_t session, const char *name, unsigned int nameLen, const char *val, int valLen ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL ) @@ -954,7 +954,7 @@ static void set_req_env( void *session, const char *name, unsigned int nameLen, RequestVars::setEnv(pSession, name, nameLen, val, valLen); } -static int get_req_content_length( void *session ) +static int get_req_content_length( lsi_session_t session ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL) @@ -963,7 +963,7 @@ static int get_req_content_length( void *session ) return pReq->getContentLength(); } -static int read_req_body( void *session, char *buf, int bufLen ) +static int read_req_body( lsi_session_t session, char *buf, int bufLen ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL) @@ -993,7 +993,7 @@ static int read_req_body( void *session, char *buf, int bufLen ) return size; } -static int is_req_body_finished( void *session ) +static int is_req_body_finished( lsi_session_t session ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (!pSession || pSession->getFlag(HSF_REQ_BODY_DONE)) @@ -1002,7 +1002,7 @@ static int is_req_body_finished( void *session ) return 0; } -static int set_req_wait_full_body( void *session ) +static int set_req_wait_full_body( lsi_session_t session ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL) @@ -1012,7 +1012,7 @@ static int set_req_wait_full_body( void *session ) return 0; } -static int set_resp_wait_full_body( void *session ) +static int set_resp_wait_full_body( lsi_session_t session ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL) @@ -1028,7 +1028,7 @@ static int set_resp_wait_full_body( void *session ) //if the response buffer to write is bigger than LSI_MAX_RESP_BUFFER_SIZE, //it will return 0 (false) means not available, otherwise return 1 (true) //LSI_MAX_RESP_BUFFER_SIZE is defined in ls.h -static int is_resp_buffer_available(void *session) +static int is_resp_buffer_available(lsi_session_t session) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL) @@ -1040,7 +1040,7 @@ static int is_resp_buffer_available(void *session) return 1; } -static int is_resp_buffer_gzippped(void *session) +static int is_resp_buffer_gzippped(lsi_session_t session) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL) @@ -1053,7 +1053,7 @@ static int is_resp_buffer_gzippped(void *session) } //return 0 is OK, -1 error -static int append_resp_body( void *session, const char *buf, int len ) +static int append_resp_body( lsi_session_t session, const char *buf, int len ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL) @@ -1067,7 +1067,7 @@ static int append_resp_body( void *session, const char *buf, int len ) //return 0 is OK, -1 error -static int append_resp_bodyv( void *session, const struct iovec *vector, int count ) +static int append_resp_bodyv( lsi_session_t session, const struct iovec *vector, int count ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL) @@ -1094,7 +1094,7 @@ static int append_resp_bodyv( void *session, const struct iovec *vector, int cou return error; } -static int init_file_type_mdata( void *session, const lsi_module_t *pModule, const char *path, int pathLen ) +static int init_file_type_mdata( lsi_session_t session, const lsi_module_t *pModule, const char *path, int pathLen ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL) @@ -1108,7 +1108,7 @@ static int init_file_type_mdata( void *session, const lsi_module_t *pModule, con return fd; } -static int send_file( void *session, const char *path, int64_t start, int64_t size ) +static int send_file( lsi_session_t session, const char *path, int64_t start, int64_t size ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL) @@ -1126,7 +1126,7 @@ static int send_file( void *session, const char *path, int64_t start, int64_t si return 0; } -static void lsi_flush( void *session ) +static void lsi_flush( lsi_session_t session ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL) @@ -1134,7 +1134,7 @@ static void lsi_flush( void *session ) pSession->flush(); } -static void lsi_end_resp( void *session ) +static void lsi_end_resp( lsi_session_t session ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL) @@ -1146,7 +1146,7 @@ static void lsi_end_resp( void *session ) #define URL_QS_OP_MASK 112 -static int set_uri_qs( void *session, int action, const char *uri, int uri_len, const char *qs, int qs_len ) +static int set_uri_qs( lsi_session_t session, int action, const char *uri, int uri_len, const char *qs, int qs_len ) { #define MAX_URI_QS_LEN 8192 char tmpBuf[MAX_URI_QS_LEN]; @@ -1286,7 +1286,7 @@ static const char * get_server_root() return HttpGlobals::s_pServerRoot; } -static void *get_module_param( void *session, const lsi_module_t *pModule ) +static void *get_module_param( lsi_session_t session, const lsi_module_t *pModule ) { ModuleConfig *pConfig = NULL; if (session) @@ -1305,7 +1305,7 @@ static void * lsiapi_get_multiplexer() { return HttpGlobals::getMultiplexer(); } -static int get_file_path_by_uri( void *session, const char * uri, int uri_len, char * path, int max_len ) +static int get_file_path_by_uri( lsi_session_t session, const char * uri, int uri_len, char * path, int max_len ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL) @@ -1313,7 +1313,7 @@ static int get_file_path_by_uri( void *session, const char * uri, int uri_len, c return pSession->getReq()->translatePath( uri, uri_len, path, max_len); } -// static int set_static_file_by_uri( void *session, const char * uri, int uri_len ) +// static int set_static_file_by_uri( lsi_session_t session, const char * uri, int uri_len ) // { // HttpSession *pSession = (HttpSession *)((LsiSession *)session); // if (pSession == NULL) @@ -1325,7 +1325,7 @@ static int get_file_path_by_uri( void *session, const char * uri, int uri_len, c // // } -// static const struct stat * get_static_file_stat( void *session ) +// static const struct stat * get_static_file_stat( lsi_session_t session ) // { // HttpSession *pSession = (HttpSession *)((LsiSession *)session); // if (pSession == NULL) @@ -1334,7 +1334,7 @@ static int get_file_path_by_uri( void *session, const char * uri, int uri_len, c // pInfo->getFileData(); // } -static const char * get_mime_type_by_suffix( void *session, const char * suffix ) +static const char * get_mime_type_by_suffix( lsi_session_t session, const char * suffix ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (pSession == NULL) @@ -1342,7 +1342,7 @@ static const char * get_mime_type_by_suffix( void *session, const char * suffix return pSession->getReq()->getMimeBySuffix( suffix ); } -static int set_force_mime_type( void * session, const char * mime ) +static int set_force_mime_type( lsi_session_t session, const char * mime ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if ( pSession == NULL || !mime ) @@ -1351,7 +1351,7 @@ static int set_force_mime_type( void * session, const char * mime ) return 0; } -static const char * get_req_handler_type( void * session ) +static const char * get_req_handler_type( lsi_session_t session ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if ( pSession == NULL ) @@ -1359,7 +1359,7 @@ static const char * get_req_handler_type( void * session ) return HandlerType::getHandlerTypeString( pSession->getCurHandler()->getType() ); } -static int get_file_stat( void * session, const char *path, int pathLen, struct stat * st ) +static int get_file_stat( lsi_session_t session, const char *path, int pathLen, struct stat * st ) { if ( !path || !st ) return -1; @@ -1372,7 +1372,7 @@ static int get_file_stat( void * session, const char *path, int pathLen, struct } -static const char * get_req_file_path( void * session, int * pathLen ) +static const char * get_req_file_path( lsi_session_t session, int * pathLen ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if ( pSession == NULL ) @@ -1392,7 +1392,7 @@ static const char * get_req_file_path( void * session, int * pathLen ) } } -static int is_access_log_on( void * session ) +static int is_access_log_on( lsi_session_t session ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if ( pSession == NULL ) @@ -1400,7 +1400,7 @@ static int is_access_log_on( void * session ) return !pSession->getFlag( HSF_ACCESS_LOG_OFF ); } -static void set_access_log( void * session, int enable ) +static void set_access_log( lsi_session_t session, int enable ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if ( pSession == NULL ) @@ -1410,7 +1410,7 @@ static void set_access_log( void * session, int enable ) } -static int get_access_log_string( void * session, const char * log_pattern, char * buf, int bufLen ) +static int get_access_log_string( lsi_session_t session, const char * log_pattern, char * buf, int bufLen ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if (( pSession == NULL )||( !log_pattern )||( !buf )) @@ -1426,7 +1426,7 @@ static const char * get_module_name( const lsi_module_t * module ) } -static int is_resp_handler_aborted( void * session ) +static int is_resp_handler_aborted( lsi_session_t session ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if ( pSession == NULL ) @@ -1436,7 +1436,7 @@ static int is_resp_handler_aborted( void * session ) } -static void * get_resp_body_buf( void * session ) +static void * get_resp_body_buf( lsi_session_t session ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if ( pSession == NULL ) @@ -1444,7 +1444,7 @@ static void * get_resp_body_buf( void * session ) return pSession->getRespCache(); } -static void * get_req_body_buf( void * session ) +static void * get_req_body_buf( lsi_session_t session ) { HttpSession *pSession = (HttpSession *)((LsiSession *)session); if ( pSession == NULL ) @@ -1514,6 +1514,13 @@ static const lsi_module_t * get_module( lsi_cb_param_t * param ) return ((LsiApiHook *)param->_cur_hook)->_module; } +static time_t get_cur_time( int32_t * usec ) +{ + if ( usec ) + *usec = DateTime::s_curTimeUs; + return DateTime::s_curTime; +} + void lsiapi_init_server_api() { @@ -1624,5 +1631,6 @@ void lsiapi_init_server_api() pApi->is_body_buf_eof = is_body_buf_eof; pApi->reset_body_buf = reset_body_buf; pApi->append_body_buf = append_body_buf; - + pApi->get_cur_time = get_cur_time; + } diff --git a/src/lsiapi/modulehandler.cpp b/src/lsiapi/modulehandler.cpp index 7a6217248..5d5218e12 100644 --- a/src/lsiapi/modulehandler.cpp +++ b/src/lsiapi/modulehandler.cpp @@ -59,7 +59,7 @@ int ModuleHandler::cleanUp(HttpSession* pSession) if ( pModuleHandler->on_clean_up ) { - int ret = pModuleHandler->on_clean_up(((void *)((LsiSession *)pSession))); + int ret = pModuleHandler->on_clean_up(pSession); if ( D_ENABLED( DL_MEDIUM ) ) { LOG_D(( pSession->getLogger(), "[%s] [%s] _handler->on_clean_up() return %d", @@ -82,7 +82,7 @@ int ModuleHandler::onWrite(HttpSession* pSession) if (pModuleHandler->on_write_resp) { - int status = pModuleHandler->on_write_resp(((void *)((LsiSession *)pSession))); + int status = pModuleHandler->on_write_resp(pSession); if ( D_ENABLED( DL_MEDIUM ) ) { LOG_D(( pSession->getLogger(), "[%s] [%s] _handler->on_write_resp() return %d", @@ -128,7 +128,7 @@ int ModuleHandler::process(HttpSession* pSession, const HttpHandler* pHandler) pSession->resetResp(); // pSession->setupRespCache(); - int ret = pModuleHandler->begin_process(((void *)((LsiSession *)pSession))); + int ret = pModuleHandler->begin_process(pSession); if ( D_ENABLED( DL_MEDIUM ) ) { LOG_D(( pSession->getLogger(), "[%s] [%s] _handler->begin_process() return %d", @@ -156,7 +156,7 @@ int ModuleHandler::onRead( HttpSession* pSession ) if (pModuleHandler->on_read_req_body) { - int ret = pModuleHandler->on_read_req_body(((void *)((LsiSession *)pSession))); + int ret = pModuleHandler->on_read_req_body(pSession); if ( D_ENABLED( DL_MEDIUM ) ) { LOG_D(( pSession->getLogger(), "[%s] [%s] _handler->on_write_resp() return %d", diff --git a/src/lsiapi/modulemanager.cpp b/src/lsiapi/modulemanager.cpp index 22bc4abf8..c290bc867 100644 --- a/src/lsiapi/modulemanager.cpp +++ b/src/lsiapi/modulemanager.cpp @@ -495,7 +495,7 @@ int ModuleConfig::saveConfig(const XmlNode *pNode, lsi_module_t *pModule, lsi_mo // // } -int ModuleConfig::parseConfig(const XmlNode *pNode, lsi_module_t *pModule, ModuleConfig *pModuleConfig) +int ModuleConfig::parseConfig(const XmlNode *pNode, lsi_module_t *pModule, ModuleConfig *pModuleConfig, int level, const char *name) { const char *pValue = NULL; @@ -524,7 +524,7 @@ int ModuleConfig::parseConfig(const XmlNode *pNode, lsi_module_t *pModule, Modul // } } - config->config = pModule->_config_parser->_parse_config(pValue, config->config); + config->config = pModule->_config_parser->_parse_config(pValue, config->config, level, name); config->own_data_flag = 2; } else @@ -533,7 +533,7 @@ int ModuleConfig::parseConfig(const XmlNode *pNode, lsi_module_t *pModule, Modul return 0; } -int ModuleConfig::parseConfigList(const XmlNodeList *moduleConfigNodeList, ModuleConfig *pModuleConfig) +int ModuleConfig::parseConfigList(const XmlNodeList *moduleConfigNodeList, ModuleConfig *pModuleConfig, int level, const char *name) { if (!moduleConfigNodeList) return 0; @@ -560,7 +560,7 @@ int ModuleConfig::parseConfigList(const XmlNodeList *moduleConfigNodeList, Modul if (moduleIter == ModuleManager::getInstance().end()) continue; - parseConfig(pNode, moduleIter.second()->getModule(), pModuleConfig); + parseConfig(pNode, moduleIter.second()->getModule(), pModuleConfig, level, name); } return ret; } diff --git a/src/lsiapi/modulemanager.h b/src/lsiapi/modulemanager.h index dad1eb977..9a6b328e9 100644 --- a/src/lsiapi/modulemanager.h +++ b/src/lsiapi/modulemanager.h @@ -150,9 +150,9 @@ class ModuleConfig : public LsiModuleData static int compare(lsi_module_config_t *config1, lsi_module_config_t *config2); static int parsePriority(const XmlNode *pModuleNode, int *priority); - static int parseConfig(const XmlNode *pModuleNode, lsi_module_t *pModule, ModuleConfig *pModuleConfig); + static int parseConfig(const XmlNode *pModuleNode, lsi_module_t *pModule, ModuleConfig *pModuleConfig, int level, const char *name); static int saveConfig(const XmlNode *pModuleUrlfilterNode, lsi_module_t *pModule, lsi_module_config_t * module_config); - static int parseConfigList(const XmlNodeList *moduleConfigNodeList, ModuleConfig *pModuleConfig); + static int parseConfigList(const XmlNodeList *moduleConfigNodeList, ModuleConfig *pModuleConfig, int level, const char *name); }; diff --git a/src/main/httpserver.cpp b/src/main/httpserver.cpp index 0a0808c59..67eaf8ba2 100644 --- a/src/main/httpserver.cpp +++ b/src/main/httpserver.cpp @@ -1236,7 +1236,7 @@ HttpListener * HttpServerImpl::configListener( const XmlNode *pNode, int isAdmin const XmlNodeList *pModuleList = p0->getChildren( "module" ); if ( pModuleList ) { - ModuleConfig::parseConfigList(pModuleList, &pListener->m_moduleConfig); + ModuleConfig::parseConfigList(pModuleList, &pListener->m_moduleConfig, LSI_SERVER_LEVEL, pName); } ModuleManager::getInstance().inheritIolinkApiHooks(&pListener->m_iolinkSessionHooks, &pListener->m_moduleConfig); @@ -2293,7 +2293,7 @@ int HttpServerImpl::configModules( const XmlNode *pRoot ) { ModuleManager::getGlobalModuleConfig()->get(i)->filters_enable = 1; } - ModuleConfig::parseConfigList(pList, ModuleManager::getGlobalModuleConfig()); + ModuleConfig::parseConfigList(pList, ModuleManager::getGlobalModuleConfig(), LSI_SERVER_LEVEL, pRoot->getName()); ModuleManager::getInstance().runModuleInit(); return 0; @@ -2439,6 +2439,7 @@ int HttpServerImpl::configServer( int reconfig, XmlNode *pRoot) if ( !reconfig ) { + SystemInfo::maxOpenFile( 4096 ); configMultiplexer(pRoot->getChild( "tuning" ) ); m_oldListeners.recvListeners(); HttpGlobals::getStdErrLogger()->initLogger( HttpGlobals::getMultiplexer() ); diff --git a/src/main/lshttpdmain.cpp b/src/main/lshttpdmain.cpp index 673a80ebd..00f98f678 100644 --- a/src/main/lshttpdmain.cpp +++ b/src/main/lshttpdmain.cpp @@ -76,7 +76,6 @@ #include #define PID_FILE DEFAULT_TMP_DIR "/lshttpd.pid" -#define SYSSTATS_FILE DEFAULT_TMP_DIR "/.sysstats" static char s_iRunning = 0; char *argv0 = NULL; @@ -258,10 +257,6 @@ void LshttpdMain::onGuardTimer() s_count = (s_count + 1) % 5; clearToStopApp(); - if ( !s_count ) - { - writeSysStats(); - } //processAdminCtrlFile( m_sCtrlFile.c_str()); checkRestartReq(); @@ -480,72 +475,6 @@ int LshttpdMain::processAdminBuffer( char * p, char * pEnd ) } -void LshttpdMain::writeSysStats() -{ - char achStatsFile[256] = ""; - char achTmpStatsFile[256]; - if ( HttpGlobals::s_psChroot ) - { - //prefix chroot here - strcpy( achStatsFile, HttpGlobals::s_psChroot->c_str() ); - } - strcat( achStatsFile, SYSSTATS_FILE ); - strcpy( achTmpStatsFile, achStatsFile ); - strcat( achTmpStatsFile, ".tmp" ); - int fd = open( achTmpStatsFile, O_WRONLY | O_CREAT, 0644 ); - if ( fd == -1 ) - LOG_ERR(( "Failed to create system statistic report file: %s", achTmpStatsFile )); - else - { - writeProcessData( fd ); - close( fd ); - rename( achTmpStatsFile, achStatsFile ); - } -} - -void LshttpdMain::writeProcessData( int fd ) -{ - char achPid[20]; - static char achPs[3][3] = { "ps", "-o", "-p" }; - static char achParam[] = "pid,nice,pri,pcpu,pmem,rss,vsz,time"; - static char achPath[] = "PATH=/bin:/usr/bin"; - char *psCmd[32] = - { - achPs[0], achPs[1], achParam - }; - psCmd[3] = achPs[2]; - - psCmd[4] = achPid; - psCmd[5] = NULL; - write( fd, "PS\n", 3 ); - - ChildProc * pProc; - pProc = (ChildProc *)m_childrenList.begin(); - while( pProc ) - { - if (( pProc->m_iState == CP_RUNNING )&&( pProc->m_pid > 0 ) ) - { - safe_snprintf( achPid, 20, "%d", pProc->m_pid ); - int pid = fork(); - if ( pid < 0) - LOG_ERR(( "fork() failed" )); - else if ( pid == 0 ) - { - dup2( fd, STDOUT_FILENO ); - putenv( achPath ); - pid = execvp( "ps", psCmd ); - if ( D_ENABLED( DL_LESS ) ) - LOG_D(( "Failed to execute 'ps' command: %s ", strerror( errno ) )); - exit( 0 ); - } - else - waitpid( pid, NULL, 0 ); - } - pProc = (ChildProc *)pProc->next(); - } - -} - #define DEFAULT_XML_CONFIG_FILE "conf/httpd_config.xml" #define DEFAULT_PLAIN_CONFIG_FILE "conf/httpd_config.conf" diff --git a/src/modules/cache/Makefile.am b/src/modules/cache/Makefile.am index 6450c3361..bbd41e2bb 100644 --- a/src/modules/cache/Makefile.am +++ b/src/modules/cache/Makefile.am @@ -1,14 +1,13 @@ +modulesdir=$(prefix)/modules -modulesir = $(DESTDIR)/modules +modules_LTLIBRARIES=cache.la +cache_la_LDFLAGS= -module -avoid-version -shared -modules_LTLIBRARIES = cache.la -cache_la_LDFLAGS = -module -avoid-version -shared +INCLUDES= -I$(top_srcdir)/src -INCLUDES = -I$(top_srcdir)/src +cache_la_METASOURCES= AUTO -cache_la_METASOURCES = AUTO - -cache_la_SOURCES =cache.cpp cacheentry.cpp cachehash.cpp cachestore.cpp ceheader.cpp dirhashcacheentry.cpp dirhashcachestore.cpp \ +cache_la_SOURCES=cache.cpp cacheentry.cpp cachehash.cpp cachestore.cpp ceheader.cpp dirhashcacheentry.cpp dirhashcachestore.cpp \ cacheconfig.cpp cachectrl.cpp \ ../../util/autostr.cpp ../../util/datetime.cpp ../../util/stringtool.cpp \ ../../util/pool.cpp ../../util/stringlist.cpp ../../util/gpointerlist.cpp \ diff --git a/src/modules/cache/Makefile.f b/src/modules/cache/Makefile.f index 7bcc66a4c..d26ac6096 100644 --- a/src/modules/cache/Makefile.f +++ b/src/modules/cache/Makefile.f @@ -4,9 +4,9 @@ OS := $(shell uname) ifeq ($(OS), Darwin) - LDFLAGS= -fPIC -g -undefined dynamic_lookup -lcrypto -Wall $(LFSFLAGS) -shared + LDFLAGS= -fPIC -g -undefined dynamic_lookup -Wall $(LFSFLAGS) -shared else - LDFLAGS= -fPIC -g -lcrypto -Wall $(LFSFLAGS) -shared + LDFLAGS= -fPIC -g -Wall $(LFSFLAGS) -shared endif SOURCES =cache.cpp cacheentry.cpp cachehash.cpp cachestore.cpp ceheader.cpp dirhashcacheentry.cpp dirhashcachestore.cpp \ diff --git a/src/modules/cache/Makefile.in b/src/modules/cache/Makefile.in index bd292c7a4..c2b7d2644 100644 --- a/src/modules/cache/Makefile.in +++ b/src/modules/cache/Makefile.in @@ -119,8 +119,8 @@ am__uninstall_files_from_dir = { \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } -am__installdirs = "$(DESTDIR)$(modulefilesdir)" -LTLIBRARIES = $(modulefiles_LTLIBRARIES) +am__installdirs = "$(DESTDIR)$(modulesdir)" +LTLIBRARIES = $(modules_LTLIBRARIES) cache_la_LIBADD = am_cache_la_OBJECTS = cache.lo cacheentry.lo cachehash.lo \ cachestore.lo ceheader.lo dirhashcacheentry.lo \ @@ -337,7 +337,6 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ -mymodules = @mymodules@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ @@ -351,8 +350,8 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -modulefilesdir = $(prefix)/modules -modulefiles_LTLIBRARIES = cache.la +modulesdir = $(prefix)/modules +modules_LTLIBRARIES = cache.la cache_la_LDFLAGS = -module -avoid-version -shared INCLUDES = -I$(top_srcdir)/src cache_la_METASOURCES = AUTO @@ -397,33 +396,33 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): -install-modulefilesLTLIBRARIES: $(modulefiles_LTLIBRARIES) +install-modulesLTLIBRARIES: $(modules_LTLIBRARIES) @$(NORMAL_INSTALL) - @list='$(modulefiles_LTLIBRARIES)'; test -n "$(modulefilesdir)" || list=; \ + @list='$(modules_LTLIBRARIES)'; test -n "$(modulesdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ - echo " $(MKDIR_P) '$(DESTDIR)$(modulefilesdir)'"; \ - $(MKDIR_P) "$(DESTDIR)$(modulefilesdir)" || exit 1; \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(modulefilesdir)'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(modulefilesdir)"; \ + echo " $(MKDIR_P) '$(DESTDIR)$(modulesdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(modulesdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(modulesdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(modulesdir)"; \ } -uninstall-modulefilesLTLIBRARIES: +uninstall-modulesLTLIBRARIES: @$(NORMAL_UNINSTALL) - @list='$(modulefiles_LTLIBRARIES)'; test -n "$(modulefilesdir)" || list=; \ + @list='$(modules_LTLIBRARIES)'; test -n "$(modulesdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ - echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(modulefilesdir)/$$f'"; \ - $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(modulefilesdir)/$$f"; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(modulesdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(modulesdir)/$$f"; \ done -clean-modulefilesLTLIBRARIES: - -test -z "$(modulefiles_LTLIBRARIES)" || rm -f $(modulefiles_LTLIBRARIES) - @list='$(modulefiles_LTLIBRARIES)'; \ +clean-modulesLTLIBRARIES: + -test -z "$(modules_LTLIBRARIES)" || rm -f $(modules_LTLIBRARIES) + @list='$(modules_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ @@ -433,7 +432,7 @@ clean-modulefilesLTLIBRARIES: } cache.la: $(cache_la_OBJECTS) $(cache_la_DEPENDENCIES) $(EXTRA_cache_la_DEPENDENCIES) - $(AM_V_CXXLD)$(cache_la_LINK) -rpath $(modulefilesdir) $(cache_la_OBJECTS) $(cache_la_LIBADD) $(LIBS) + $(AM_V_CXXLD)$(cache_la_LINK) -rpath $(modulesdir) $(cache_la_OBJECTS) $(cache_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -657,7 +656,7 @@ check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: - for dir in "$(DESTDIR)$(modulefilesdir)"; do \ + for dir in "$(DESTDIR)$(modulesdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am @@ -692,7 +691,7 @@ maintainer-clean-generic: @echo "it deletes files that may require special tools to rebuild." clean: clean-am -clean-am: clean-generic clean-libtool clean-modulefilesLTLIBRARIES \ +clean-am: clean-generic clean-libtool clean-modulesLTLIBRARIES \ mostlyclean-am distclean: distclean-am @@ -713,7 +712,7 @@ info: info-am info-am: -install-data-am: install-modulefilesLTLIBRARIES +install-data-am: install-modulesLTLIBRARIES install-dvi: install-dvi-am @@ -759,24 +758,24 @@ ps: ps-am ps-am: -uninstall-am: uninstall-modulefilesLTLIBRARIES +uninstall-am: uninstall-modulesLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ - clean-libtool clean-modulefilesLTLIBRARIES cscopelist-am ctags \ + clean-libtool clean-modulesLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-modulefilesLTLIBRARIES \ + install-info-am install-man install-modulesLTLIBRARIES \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ - uninstall-modulefilesLTLIBRARIES + uninstall-modulesLTLIBRARIES #noinst_HEADERS = diff --git a/src/modules/cache/cache.cpp b/src/modules/cache/cache.cpp index 598d67495..bdfc9758a 100644 --- a/src/modules/cache/cache.cpp +++ b/src/modules/cache/cache.cpp @@ -125,9 +125,37 @@ const char *paramArray[] = { "maxstaleage", "enableprivatecache", "privateexpireinseconds", + "storagepath", NULL //Must have NULL in the last item }; +static const char* parseLineStr(const char *buf, const char *key, int& len) +{ + int bufLen = strlen(buf); + int keyLen = strlen(key); + const char *p0, *p1; + + len = 0; + if (bufLen <= keyLen || (p0 = strcasestr(buf, key)) == NULL) + return NULL; + + p0 += keyLen; + while (p0 < buf + bufLen && (*p0 == ' ' || *p0 == '\t')) + ++p0; + + p1 = p0; + /** + * TODO: when plain conf, needn't these checking + * Just use: len = buf + bufLen - p0; + * For tail already trimmed + */ + while(p1 < buf + bufLen && *p1 != ' ' && *p1 != '\t' && *p1 != '\n' && *p1 != '\r') + ++p1; + + len = p1 - p0; + return p0; +} + static int parseLine(const char *buf, const char *key, int minValue, int maxValue, int defValue) { const char *paramEnd = buf + strlen(buf); @@ -151,7 +179,7 @@ static int parseLine(const char *buf, const char *key, int minValue, int maxValu return val; } -static void * parseConfig( const char *param, void *_initial_config ) +static void * parseConfig( const char *param, void *_initial_config, int level, const char *name ) { CacheConfig *pInitConfig = (CacheConfig *)_initial_config; CacheConfig *pConfig = new CacheConfig; @@ -203,6 +231,18 @@ static void * parseConfig( const char *param, void *_initial_config ) pConfig->setConfigBit( CACHE_PRIVATE_AGE_SET, 1 ); } + //In context level, do not parse and use this parameter + int valLen = 0; + const char *p = parseLineStr( param, "storagepath", valLen ); + if (p && valLen > 0) + { + if (level != LSI_CONTEXT_LEVEL) + pConfig->setStoragePath(p, valLen); + else + g_api->log(LSI_LOG_INFO, "[%s]context [%s] shouldn't have 'storagepath' parameter.\n", + ModuleNameString, name); + } + return (void *)pConfig; } @@ -228,19 +268,17 @@ static int initGData() } DirHashCacheStore *pDirHashCacheStore = (DirHashCacheStore *)g_api->get_gdata(pCont, CACHEMODULEKEY, CACHEMODULEKEYLEN, release_cb, 0, NULL); - if (!pDirHashCacheStore) + if (pDirHashCacheStore) + { + g_api->log(LSI_LOG_ERROR, "[%s]GDItem init error.", ModuleNameString); + return -1; + } + else { - char cachePath[max_file_len] = {0}; - strcpy(cachePath, g_api->get_server_root()); - strcat(cachePath, CACHEMODULEROOT); pDirHashCacheStore = new DirHashCacheStore; - pDirHashCacheStore->setStorageRoot(cachePath); g_api->set_gdata(pCont, CACHEMODULEKEY, CACHEMODULEKEYLEN, pDirHashCacheStore, -1, release_cb, 1, NULL); return 0; } - - g_api->log(LSI_LOG_ERROR, "[%s]GDItem init error.", ModuleNameString); - return -1; } void calcCacheHash( const char * pURI, int iURILen, @@ -270,12 +308,9 @@ void calcCacheHash( const char * pURI, int iURILen, } } -short hasCache(struct lsi_cb_param_t *rec, const char *uri, int uriLen, DirHashCacheStore **pDirHashCacheStore, +short hasCache(lsi_cb_param_t *rec, const char *uri, int uriLen, DirHashCacheStore *pDirHashCacheStore, CacheHash *cePublicHash, CacheHash *cePrivateHash, CacheConfig *pConfig, CacheEntry **pEntry) { - lsi_gdata_cont_val_t *pCont = g_api->get_gdata_container(LSI_CONTAINER_MEMORY, LSI_MODULE_CONTAINER_KEY, LSI_MODULE_CONTAINER_KEYLEN); - *pDirHashCacheStore = (DirHashCacheStore *)g_api->get_gdata(pCont, CACHEMODULEKEY, CACHEMODULEKEYLEN, release_cb, 0, NULL); - int cookieLen, iQSLen, ipLen; const char * pCookie = g_api->get_req_cookies(rec->_session, &cookieLen); const char * pIP = g_api->get_client_ip( rec->_session, &ipLen ); @@ -284,12 +319,12 @@ short hasCache(struct lsi_cb_param_t *rec, const char *uri, int uriLen, DirHashC //Try private one first long lastCacheFlush = (long)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_IP); - *pEntry = (*pDirHashCacheStore)->getCacheEntry(*cePrivateHash, uri, uriLen, pQS, iQSLen, pIP, ipLen, pCookie, cookieLen, lastCacheFlush, pConfig->getMaxStale()); + *pEntry = pDirHashCacheStore->getCacheEntry(*cePrivateHash, uri, uriLen, pQS, iQSLen, pIP, ipLen, pCookie, cookieLen, lastCacheFlush, pConfig->getMaxStale()); if (*pEntry && (!(*pEntry)->isStale() || (*pEntry)->isUpdating())) return CE_STATE_HAS_RIVATECACHE; //Second, check if can use public one - *pEntry = (*pDirHashCacheStore)->getCacheEntry(*cePublicHash, uri, uriLen, pQS, iQSLen, NULL, 0, NULL, 0, 0, pConfig->getMaxStale()); + *pEntry = pDirHashCacheStore->getCacheEntry(*cePublicHash, uri, uriLen, pQS, iQSLen, NULL, 0, NULL, 0, 0, pConfig->getMaxStale()); if (*pEntry && (!(*pEntry)->isStale() || (*pEntry)->isUpdating())) return CE_STATE_HAS_PUBLIC_CACHE; @@ -343,7 +378,7 @@ int writeHttpHeader(int fd, AutoStr2 *str, const char *s, int len) return len; } -void getRespHeader(void *session, int header_index, char **buf, int *length) +void getRespHeader(lsi_session_t session, int header_index, char **buf, int *length) { struct iovec iov[1] = {{NULL, 0}}; int iovCount = g_api->get_resp_header(session, header_index, NULL, 0, iov, 1); @@ -359,7 +394,7 @@ void getRespHeader(void *session, int header_index, char **buf, int *length) } } -void clearHooks(void *session) +void clearHooks(lsi_session_t session) { MyMData *myData = (MyMData *) g_api->get_module_data(session, &MNAME, LSI_MODULE_DATA_HTTP); if (myData) @@ -370,7 +405,7 @@ void clearHooks(void *session) g_api->remove_session_hook( session, LSI_HKPT_RECVED_RESP_BODY, &MNAME ); } -static int cancelCache(struct lsi_cb_param_t *rec) +static int cancelCache(lsi_cb_param_t *rec) { MyMData *myData = (MyMData *)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_HTTP); if (myData != NULL && myData->iCacheState == CE_STATE_WILLCACHE) @@ -378,17 +413,17 @@ static int cancelCache(struct lsi_cb_param_t *rec) myData->pDirHashCacheStore->cancelEntry(myData->pEntry, 1); } clearHooks(rec->_session); - g_api->log(LSI_LOG_ERROR, "[%s]cancel cache.", ModuleNameString); + g_api->session_log(rec->_session, LSI_LOG_DEBUG, "[%s]cache cancelled.\n", ModuleNameString); return 0; } -static int createEntry(struct lsi_cb_param_t *rec) +static int createEntry(lsi_cb_param_t *rec) { MyMData *myData = (MyMData *)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_HTTP); if (myData == NULL) { clearHooks(rec->_session); - g_api->log(LSI_LOG_ERROR, "[%s]createEntry error.", ModuleNameString); + g_api->session_log(rec->_session, LSI_LOG_ERROR, "[%s]internal error during createEntry.\n", ModuleNameString); return 0; } @@ -397,33 +432,36 @@ static int createEntry(struct lsi_cb_param_t *rec) const char * pCookie = g_api->get_req_cookies(rec->_session, &cookieLen); const char * pIP = g_api->get_client_ip( rec->_session, &ipLen ); const char *pQS = g_api->get_req_query_string( rec->_session, &iQSLen ); + int errorcode; if (myData->cacheCtrl.isPrivateCacheable()) - myData->pEntry = myData->pDirHashCacheStore->createCacheEntry(myData->cePrivateHash, myData->orgUri, uriLen, pQS, iQSLen, pIP, ipLen, pCookie, cookieLen, 1); + myData->pEntry = myData->pDirHashCacheStore->createCacheEntry(myData->cePrivateHash, myData->orgUri, uriLen, pQS, iQSLen, pIP, ipLen, pCookie, cookieLen, 1, &errorcode); else// if (myData->cacheCtrl.isPublicCacheable()) - myData->pEntry = myData->pDirHashCacheStore->createCacheEntry(myData->cePublicHash, myData->orgUri, uriLen, pQS, iQSLen, NULL, 0, NULL, 0, 1); + myData->pEntry = myData->pDirHashCacheStore->createCacheEntry(myData->cePublicHash, myData->orgUri, uriLen, pQS, iQSLen, NULL, 0, NULL, 0, 1, &errorcode); if (myData->pEntry == NULL) { + g_api->session_log(rec->_session, LSI_LOG_ERROR, "[%s] createEntry failed, code [%d].\n", ModuleNameString, errorcode); clearHooks(rec->_session); - g_api->log(LSI_LOG_ERROR, "[%s]createEntry failed.", ModuleNameString); } + else + myData->iCacheState = CE_STATE_WILLCACHE; - myData->iCacheState = CE_STATE_WILLCACHE; return 0; } -int cacheTofile(struct lsi_cb_param_t *rec) +int cacheTofile(lsi_cb_param_t *rec) { MyMData *myData = (MyMData *)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_HTTP); if (myData == NULL) { - g_api->log(LSI_LOG_ERROR, "[%s]cacheTofile error 1.", ModuleNameString); + g_api->session_log(rec->_session, LSI_LOG_ERROR, "[%s]internal error during cacheTofile.\n", ModuleNameString); return 0; } if (myData->pEntry == NULL || myData->iCacheState != CE_STATE_WILLCACHE) { - g_api->log(LSI_LOG_ERROR, "[%s]cacheTofile error 2.", ModuleNameString); + g_api->session_log(rec->_session, LSI_LOG_ERROR, "[%s]cacheTofile error, code[%p %d].\n", + ModuleNameString, myData->pEntry, myData->iCacheState); clearHooks(rec->_session); return 0; } @@ -434,6 +472,8 @@ int cacheTofile(struct lsi_cb_param_t *rec) int iovCount = g_api->get_resp_header(rec->_session, LSI_RESP_HEADER_SET_COOKIE, NULL, 0, iov, 1); if (iov[0].iov_len > 0 && iovCount == 1) { + g_api->session_log(rec->_session, LSI_LOG_DEBUG, "[%s]cacheTofile to be cancelled for having respcookie.\n", + ModuleNameString); cancelCache(rec); return 0; } @@ -442,6 +482,8 @@ int cacheTofile(struct lsi_cb_param_t *rec) const char *phandlerType = g_api->get_req_handler_type(rec->_session); if (phandlerType && memcmp("static", phandlerType, 6) == 0) { + g_api->session_log(rec->_session, LSI_LOG_DEBUG, "[%s]cacheTofile to be cancelled for static file type.\n", + ModuleNameString); cancelCache(rec); return 0; } @@ -450,6 +492,8 @@ int cacheTofile(struct lsi_cb_param_t *rec) int code = g_api->get_status_code(rec->_session); if (code >= 300) { + g_api->session_log(rec->_session, LSI_LOG_DEBUG, "[%s]cacheTofile to be cancelled for error page.\n", + ModuleNameString); cancelCache(rec); return 0; } @@ -555,7 +599,7 @@ int cacheTofile(struct lsi_cb_param_t *rec) myData->iCacheState = CE_STATE_CACHED; //Succeed g_api->free_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_HTTP, httpRelease); - g_api->session_log(rec->_session, LSI_LOG_DEBUG, "[%s:cacheTofile] stored,m size %ld\n", + g_api->session_log(rec->_session, LSI_LOG_DEBUG, "[%s:cacheTofile] stored, size %ld\n", ModuleNameString, offset); return 0; } @@ -627,20 +671,31 @@ int getCacheUserData(lsi_cb_param_t * rec) return 0; } -static int checkAssignHandler(struct lsi_cb_param_t *rec) +int createCachePath(const char *path, int mode) +{ + struct stat st; + if ( stat( path, &st ) == -1 ) + { + if ( mkdir( path, mode ) == -1 ) + return -1; + } + return 0; +} + +static int checkAssignHandler(lsi_cb_param_t *rec) { char httpMethod[10] = {0}; int uriLen = g_api->get_req_org_uri(rec->_session, NULL, 0); if ( uriLen <= 0 ) { - g_api->log(LSI_LOG_ERROR, "[%s]checkAssignHandler error 1.", ModuleNameString); + g_api->session_log(rec->_session, LSI_LOG_ERROR, "[%s]checkAssignHandler error 1.\n", ModuleNameString); return 0; } CacheConfig *pConfig = (CacheConfig *)g_api->get_module_param( rec->_session, &MNAME ); if ( !pConfig ) { - g_api->log(LSI_LOG_ERROR, "[%s]checkAssignHandler error 2.", ModuleNameString); + g_api->session_log(rec->_session, LSI_LOG_ERROR, "[%s]checkAssignHandler error 2.\n", ModuleNameString); return 0; } @@ -676,7 +731,7 @@ static int checkAssignHandler(struct lsi_cb_param_t *rec) if (method == HTTP_UNKNOWN || method == HTTP_POST) { - g_api->log(LSI_LOG_INFO, "[%s]checkAssignHandler returned, method %s[%d].", ModuleNameString, httpMethod, method); + g_api->session_log(rec->_session, LSI_LOG_INFO, "[%s]checkAssignHandler returned, method %s[%d].\n", ModuleNameString, httpMethod, method); return 0; } @@ -695,6 +750,8 @@ static int checkAssignHandler(struct lsi_cb_param_t *rec) ( pConfig->isPublicPrivateEnabled() == 0 || (!pConfig->isSet(CACHE_QS_CACHE) && pQS && iQSLen > 0)) ) { + g_api->session_log(rec->_session, LSI_LOG_INFO, "[%s]checkAssignHandler returned, for cache disabled or has QS but qscache disabled.\n", + ModuleNameString); clearHooks(rec->_session); return 0; } @@ -728,6 +785,7 @@ static int checkAssignHandler(struct lsi_cb_param_t *rec) cacheCtrl.parse((const char *)cacheEnv, cacheEnvLen); if (cacheCtrl.isCacheOff()) { + g_api->session_log(rec->_session, LSI_LOG_INFO, "[%s]checkAssignHandler returned, for cache disabled.\n", ModuleNameString); clearHooks(rec->_session); return 0; } @@ -743,7 +801,29 @@ static int checkAssignHandler(struct lsi_cb_param_t *rec) myData->pConfig = pConfig; myData->orgUri = uri; myData->iMethod = method; - myData->iCacheState = hasCache(rec, myData->orgUri, uriLen, &myData->pDirHashCacheStore, &myData->cePublicHash, &myData->cePrivateHash, pConfig, &myData->pEntry); + + lsi_gdata_cont_val_t *pCont = g_api->get_gdata_container(LSI_CONTAINER_MEMORY, LSI_MODULE_CONTAINER_KEY, LSI_MODULE_CONTAINER_KEYLEN); + myData->pDirHashCacheStore = (DirHashCacheStore *)g_api->get_gdata(pCont, CACHEMODULEKEY, CACHEMODULEKEYLEN, release_cb, 0, NULL); + + char cachePath[max_file_len] = {0}; + const char *pPath = myData->pConfig->getStoragePath(); + if (!pPath || strlen(pPath) == 0) + pPath = CACHEMODULEROOT; + + if (pPath[0] != '/') + strcpy(cachePath, g_api->get_server_root()); + + strcat(cachePath, pPath); + if (createCachePath(cachePath, 0700) == -1) + { + g_api->session_log(rec->_session, LSI_LOG_ERROR, "[%s]checkAssignHandler failed to create directory [%s].\n", + ModuleNameString, cachePath); + clearHooks(rec->_session); + return 0; + } + myData->pDirHashCacheStore->setStorageRoot(cachePath); + + myData->iCacheState = hasCache(rec, myData->orgUri, uriLen, myData->pDirHashCacheStore, &myData->cePublicHash, &myData->cePrivateHash, pConfig, &myData->pEntry); g_api->set_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_HTTP, (void *)myData); } //multiple calling of this function, Cachectrl may be updated @@ -755,7 +835,7 @@ static int checkAssignHandler(struct lsi_cb_param_t *rec) myData->iMethod == HTTP_REFRESH) { g_api->register_req_handler( rec->_session, &MNAME, 0); - g_api->log(LSI_LOG_INFO, "[%s]checkAssignHandler register_req_handler OK.", ModuleNameString); + g_api->session_log(rec->_session, LSI_LOG_INFO, "[%s]checkAssignHandler register_req_handler OK.\n", ModuleNameString); } else if (myData->iMethod == HTTP_GET && myData->iCacheState == CE_STATE_NOCACHE) { @@ -764,12 +844,12 @@ static int checkAssignHandler(struct lsi_cb_param_t *rec) g_api->add_session_hook( rec->_session, LSI_HKPT_HANDLER_RESTART, &MNAME, cancelCache, LSI_HOOK_LAST, 0 ); g_api->add_session_hook( rec->_session, LSI_HKPT_RECVED_RESP_BODY, &MNAME, cacheTofile, LSI_HOOK_LAST, 0 ); - g_api->log(LSI_LOG_INFO, "[%s]checkAssignHandler Add Hooks.", ModuleNameString); + g_api->session_log(rec->_session, LSI_LOG_INFO, "[%s]checkAssignHandler Add Hooks.\n", ModuleNameString); } else { g_api->free_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_HTTP, httpRelease); - g_api->log(LSI_LOG_INFO, "[%s]checkAssignHandler will do nothing and quit.", ModuleNameString); + g_api->session_log(rec->_session, LSI_LOG_INFO, "[%s]checkAssignHandler won't do anything and quit.\n", ModuleNameString); } return 0; @@ -792,12 +872,12 @@ static int init( lsi_module_t * pModule ) g_api->register_env_handler("setcachedata", 12, setCacheUserData); g_api->register_env_handler("getcachedata", 12, getCacheUserData); - g_api->add_hook( LSI_HKPT_RECV_REQ_HEADER, pModule, checkAssignHandler, LSI_HOOK_LAST, 0 ); + g_api->add_hook( LSI_HKPT_URI_MAP, pModule, checkAssignHandler, LSI_HOOK_LAST, 0 ); return 0; } //1 yes, 0 no -int isModified(void *session, CeHeader &CeHeader, char *etag, int etagLen) +int isModified(lsi_session_t session, CeHeader &CeHeader, char *etag, int etagLen) { int len; const char *buf = NULL; @@ -817,11 +897,14 @@ int isModified(void *session, CeHeader &CeHeader, char *etag, int etagLen) return 1; } -static int myhandler_process(void *session) +static int myhandler_process(lsi_session_t session) { MyMData *myData = (MyMData *)g_api->get_module_data(session, &MNAME, LSI_MODULE_DATA_HTTP); if (!myData) + { + g_api->session_log(session, LSI_LOG_ERROR, "[%s]internal error during myhandler_process.\n", ModuleNameString); return 500; + } if (myData->iMethod == HTTP_PURGE || myData->iMethod == HTTP_REFRESH) { @@ -969,6 +1052,6 @@ static int myhandler_process(void *session) return ret; } -struct lsi_handler_t cache_handler = { myhandler_process, NULL, NULL, NULL }; -struct lsi_config_t cacheDealConfig = { parseConfig, freeConfig, paramArray }; -lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, init, &cache_handler, &cacheDealConfig, "cache v1.1", {0} }; +lsi_handler_t cache_handler = { myhandler_process, NULL, NULL, NULL }; +lsi_config_t cacheDealConfig = { parseConfig, freeConfig, paramArray }; +lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, init, &cache_handler, &cacheDealConfig, "cache v1.2", {0} }; diff --git a/src/modules/cache/cacheconfig.cpp b/src/modules/cache/cacheconfig.cpp index 37373af20..6f76cd420 100644 --- a/src/modules/cache/cacheconfig.cpp +++ b/src/modules/cache/cacheconfig.cpp @@ -23,6 +23,7 @@ CacheConfig::CacheConfig() , m_defaultAge(86400) , m_privateAge(60) , m_iMaxStale( 0 ) + , m_sStoragePath("") { } @@ -43,6 +44,7 @@ void CacheConfig::inherit( const CacheConfig * pParent ) m_iMaxStale = pParent->m_iMaxStale; m_iCacheFlag = (m_iCacheFlag & m_iCacheConfigBits)| (pParent->m_iCacheFlag & ~m_iCacheConfigBits ); + m_sStoragePath.setStr(pParent->getStoragePath()); } } diff --git a/src/modules/cache/cacheconfig.h b/src/modules/cache/cacheconfig.h index 8306c5393..1ff8cc66b 100644 --- a/src/modules/cache/cacheconfig.h +++ b/src/modules/cache/cacheconfig.h @@ -18,6 +18,7 @@ #ifndef CACHECONFIG_H #define CACHECONFIG_H +#include "util/autostr.h" #define CACHE_ENABLED (1<<0) //#define CACHE_POST_NOCACHE (1<<1) @@ -55,6 +56,9 @@ class CacheConfig void setMaxStale( int age ) { m_iMaxStale = age; } int getMaxStale() const { return m_iMaxStale; } + void setStoragePath( const char * s, int len){ m_sStoragePath.setStr(s, len); } + const char* getStoragePath() const { return m_sStoragePath.c_str(); } + int isPrivateEnabled() const { return m_iCacheFlag & CACHE_PRIVATE_ENABLED; } int isPublicPrivateEnabled() const { return m_iCacheFlag & ( CACHE_PRIVATE_ENABLED | CACHE_ENABLED ); } @@ -70,6 +74,7 @@ class CacheConfig int m_defaultAge; int m_privateAge; int m_iMaxStale; + AutoStr2 m_sStoragePath; }; #endif diff --git a/src/modules/cache/cachestore.h b/src/modules/cache/cachestore.h index 39b28a1ec..234fd6fb0 100644 --- a/src/modules/cache/cachestore.h +++ b/src/modules/cache/cachestore.h @@ -56,7 +56,7 @@ class CacheStore : public HashStringMap const char * pQS, int pQSLen, const char * pIP, int ipLen, const char * pCookie, int cookieLen, - int force ) = 0; + int force, int* errorcode ) = 0; virtual CacheEntry * getCacheEntry( const char * pKey, int keyLen ) = 0; diff --git a/src/modules/cache/dirhashcachestore.cpp b/src/modules/cache/dirhashcachestore.cpp index ab2abe0d7..4c6838706 100644 --- a/src/modules/cache/dirhashcachestore.cpp +++ b/src/modules/cache/dirhashcachestore.cpp @@ -250,7 +250,7 @@ CacheEntry * DirHashCacheStore::createCacheEntry( const CacheHash& hash, const char * pQS, int iQSLen, const char * pIP, int ipLen, const char * pCookie, int cookieLen, - int force ) + int force, int* errorcode ) { char achBuf[4096]; int n = buildCacheLocation( achBuf, 4096, hash ); @@ -271,7 +271,10 @@ CacheEntry * DirHashCacheStore::createCacheEntry( const CacheHash& hash, if ( DateTime_s_curTime - st.st_mtime > 120 ) unlink( achBuf ); else + { + *errorcode = -1; return NULL; + } } } achBuf[n - 2 * HASH_KEY_LEN - 1] = 0; @@ -285,22 +288,32 @@ CacheEntry * DirHashCacheStore::createCacheEntry( const CacheHash& hash, { if (( mkdir( achBuf, 0700 ) == -1 )&&( errno != EEXIST )) { + *errorcode = -2; return NULL; } } achBuf[ n - 2 * HASH_KEY_LEN - 5 ] = '/'; if ( mkdir( achBuf, 0700 ) == -1 ) + { + *errorcode = -3; return NULL; + } } achBuf[ n - 2 * HASH_KEY_LEN - 3 ] = '/'; if ( mkdir( achBuf, 0700 ) == -1 ) + { + *errorcode = -4; return NULL; + } } achBuf[n - 2 * HASH_KEY_LEN - 1 ] = '/'; int fd = ::open( achBuf, O_RDWR | O_CREAT | O_TRUNC | O_EXCL, 0600 ); if ( fd == -1 ) + { + *errorcode = -5; return NULL; + } ::fcntl( fd, F_SETFD, FD_CLOEXEC ); //LOG_INFO(( "createCacheEntry(), open fd: %d", fd )); @@ -317,6 +330,7 @@ CacheEntry * DirHashCacheStore::createCacheEntry( const CacheHash& hash, CacheStore::iterator iter = find( hash.getKey() ); if ( iter != end() ) iter.second()->setUpdating( 1 ); + *errorcode = 0; return pEntry; } diff --git a/src/modules/cache/dirhashcachestore.h b/src/modules/cache/dirhashcachestore.h index c60c4be6e..dcabd3adb 100644 --- a/src/modules/cache/dirhashcachestore.h +++ b/src/modules/cache/dirhashcachestore.h @@ -66,7 +66,7 @@ class DirHashCacheStore : public CacheStore const char * pQS, int pQSLen, const char * pIP, int ipLen, const char * pCookie, int cookieLen, - int force ); + int force, int* errorcode ); virtual void cancelEntry( CacheEntry * pEntry, int remove ); @@ -80,7 +80,7 @@ class DirHashCacheStore : public CacheStore virtual int publish( CacheEntry * pEntry ); virtual void removePermEntry( CacheEntry * pEntry ); - int& nio_stat(char achBuf[4096], stat* st); + int& nio_stat(char achBuf[4096], struct stat* st); }; diff --git a/src/modules/modgzip/modgzip.cpp b/src/modules/modgzip/modgzip.cpp index 5e3ad5fce..c076acfc8 100644 --- a/src/modules/modgzip/modgzip.cpp +++ b/src/modules/modgzip/modgzip.cpp @@ -134,7 +134,7 @@ static int init_Z_State_Buf( ZBufInfo& zBufInfo ) return ret; } -static int initZstream( struct lsi_cb_param_t *rec, lsi_module_t *pModule, z_stream *pStream, uint8_t compressLevel ) +static int initZstream( lsi_cb_param_t *rec, lsi_module_t *pModule, z_stream *pStream, uint8_t compressLevel ) { int ret = 0; pStream->avail_in = 0; @@ -158,7 +158,7 @@ static int initZstream( struct lsi_cb_param_t *rec, lsi_module_t *pModule, z_str return ret; } -int flushLoopBuf( struct lsi_cb_param_t *rec, int iZState, LoopBuff *pBuff ) +int flushLoopBuf( lsi_cb_param_t *rec, int iZState, LoopBuff *pBuff ) { int written = 0; int sz = 0; @@ -196,7 +196,7 @@ static int clearDataPartR( lsi_cb_param_t *rec ) return releaseDataPartR( rec, (lsi_module_t *)g_api->get_module(rec) ); } -static int compressbuf( struct lsi_cb_param_t *rec, lsi_module_t *pModule, int isSend ) +static int compressbuf( lsi_cb_param_t *rec, lsi_module_t *pModule, int isSend ) { ModgzipMData *myData = ( ModgzipMData * ) g_api->get_module_data( rec->_session, pModule, LSI_MODULE_DATA_HTTP ); if ( !myData ) @@ -345,7 +345,7 @@ static int init( lsi_module_t * pModule ) lsi_module_t modcompress = { LSI_MODULE_SIGNATURE, init, NULL, NULL, MODULE_VERSION, {0} }; lsi_module_t moddecompress = { LSI_MODULE_SIGNATURE, init, NULL, NULL, MODULE_VERSION, {0} }; -static int addHooks( void *session, lsi_module_t *pModule, int isSend, int priority, uint8_t compressLevel ) +static int addHooks( lsi_session_t session, lsi_module_t *pModule, int isSend, int priority, uint8_t compressLevel ) { ModgzipMData *myData = ( ModgzipMData * ) g_api->get_module_data( session, pModule, LSI_MODULE_DATA_HTTP ); if ( !myData ) @@ -401,7 +401,7 @@ static int addHooks( void *session, lsi_module_t *pModule, int isSend, int prior } //The below is the only function exported -int addModgzipFilter( void *session, int isSend, uint8_t compressLevel, int priority ) +int addModgzipFilter( lsi_session_t session, int isSend, uint8_t compressLevel, int priority ) { if ( compressLevel == 0 ) return addHooks( session, &moddecompress, isSend, priority, 0 ); diff --git a/src/modules/prelinkedmods.cpp b/src/modules/prelinkedmods.cpp index 6dee3957e..17eed34ac 100644 --- a/src/modules/prelinkedmods.cpp +++ b/src/modules/prelinkedmods.cpp @@ -5,7 +5,7 @@ extern lsi_module_t modcompress; extern lsi_module_t moddecompress; -extern int addModgzipFilter(void *session, int isSend, uint8_t compressLevel, int priority); +extern int addModgzipFilter(lsi_session_t session, int isSend, uint8_t compressLevel, int priority); typedef struct { const char * _pName; diff --git a/src/socket/Makefile.in b/src/socket/Makefile.in index 09c6fbfca..3ce3bd641 100644 --- a/src/socket/Makefile.in +++ b/src/socket/Makefile.in @@ -293,7 +293,6 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ -mymodules = @mymodules@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ diff --git a/src/spdy/Makefile.in b/src/spdy/Makefile.in index 9baa83902..b3771ab12 100644 --- a/src/spdy/Makefile.in +++ b/src/spdy/Makefile.in @@ -294,7 +294,6 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ -mymodules = @mymodules@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ diff --git a/src/ssi/Makefile.in b/src/ssi/Makefile.in index bbdb2ad5d..8109b2778 100644 --- a/src/ssi/Makefile.in +++ b/src/ssi/Makefile.in @@ -291,7 +291,6 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ -mymodules = @mymodules@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ diff --git a/src/sslpp/Makefile.in b/src/sslpp/Makefile.in index eb987dbb6..5e332b166 100644 --- a/src/sslpp/Makefile.in +++ b/src/sslpp/Makefile.in @@ -292,7 +292,6 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ -mymodules = @mymodules@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ diff --git a/src/test/lsiapi/envhandler.cpp b/src/test/lsiapi/envhandler.cpp index d248283cb..92207d765 100644 --- a/src/test/lsiapi/envhandler.cpp +++ b/src/test/lsiapi/envhandler.cpp @@ -112,7 +112,7 @@ TEST(INIT_LSIAPI) //if need to test below cases //Pleaes comment out one line in -//LSIAPI void set_req_env( void *session, const char *name, unsigned int nameLen, const char *val, int valLen ) +//LSIAPI void set_req_env( lsi_session_t session, const char *name, unsigned int nameLen, const char *val, int valLen ) //COMMENT OUT ---> pReq->addEnv( name, nameLen, val, valLen ); //otherwise will cause crash for pReq is NULL now // @@ -120,7 +120,7 @@ TEST(envManagerTest2) { //FIXME: unit test crash, comment out for now. /* - void *session = (void *)100; + lsi_session_t session = (void *)100; LsiapiBridge::getLsiapiFunctions()->set_req_env(session, "cache", 5, (void *)"1", 1); LsiapiBridge::getLsiapiFunctions()->set_req_env(session, "cache", 5, (void *)"22", 2); diff --git a/src/util/Makefile.in b/src/util/Makefile.in index 62108d62e..8db9c878d 100644 --- a/src/util/Makefile.in +++ b/src/util/Makefile.in @@ -328,7 +328,6 @@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ -mymodules = @mymodules@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ diff --git a/src/util/poolalloc.h b/src/util/poolalloc.h index 0a329cef9..68e8715b8 100644 --- a/src/util/poolalloc.h +++ b/src/util/poolalloc.h @@ -1,20 +1,20 @@ -/***************************************************************************** -* Open LiteSpeed is an open source HTTP server. * -* Copyright (C) 2013 LiteSpeed Technologies, Inc. * -* * -* This program is free software: you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation, either version 3 of the License, or * -* (at your option) any later version. * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU General Public License * -* along with this program. If not, see http://www.gnu.org/licenses/. * -*****************************************************************************/ +/***************************************************************************** +* Open LiteSpeed is an open source HTTP server. * +* Copyright (C) 2013 LiteSpeed Technologies, Inc. * +* * +* This program is free software: you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation, either version 3 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program. If not, see http://www.gnu.org/licenses/. * +*****************************************************************************/ #ifndef _POOLALLOC_H_ #define _POOLALLOC_H_ @@ -74,7 +74,7 @@ class PoolAllocator char * _Charalloc(size_type _Size) { - return m_pPool->allocate( _Size ); + return (char *)(m_pPool->allocate( _Size )); } diff --git a/src/util/sysinfo/systeminfo.cpp b/src/util/sysinfo/systeminfo.cpp index 835c1e5f0..e603cd212 100644 --- a/src/util/sysinfo/systeminfo.cpp +++ b/src/util/sysinfo/systeminfo.cpp @@ -44,8 +44,8 @@ unsigned long long SystemInfo::maxOpenFile( unsigned long long max) iMaxOpenFiles = rl.rlim_cur; if (( rl.rlim_cur != RLIM_INFINITY )&&( max > rl.rlim_cur )) { - if (( max <= rl.rlim_max ) || getuid() ) - rl.rlim_cur = rl.rlim_max; + if (rl.rlim_cur < max && max <= rl.rlim_max) + rl.rlim_cur = max; else rl.rlim_cur = rl.rlim_max = max; //if ( rl.rlim_cur == RLIM_INFINITY )