Skip to content

Commit 5fb86a0

Browse files
committed
Check in 1.5.0 RC1
1 parent 6c7e6d0 commit 5fb86a0

File tree

286 files changed

+20920
-4063
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

286 files changed

+20920
-4063
lines changed

CMakeLists.txt

+30-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
cmake_minimum_required(VERSION 2.8)
2+
set( CMAKE_EXPORT_COMPILE_COMMANDS ON)
23

34
Project(openlitespeed)
45
INCLUDE( ${PROJECT_SOURCE_DIR}/CMakeModules/common.cmake)
@@ -7,7 +8,7 @@ set(openlitespeed_MAJOR_VERSION 1)
78
set(openlitespeed_MINOR_VERSION 4)
89
set(openlitespeed_PATCH_VERSION 0)
910
set(openlitespeed_VERSION
10-
${FOOBAR_MAJOR_VERSION}.${FOOBAR_MINOR_VERSION}.${FOOBAR_PATCH_VERSION})
11+
${FOOBAR_MAJOR_VERSION}.${FOOBAR_MINOR_VERSION}.${FOOBAR_PATCH_VERSION})
1112

1213
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
1314

@@ -17,18 +18,33 @@ link_directories( ${PROJECT_SOURCE_DIR}/../thirdparty/lib/)
1718
SET (CMAKE_C_COMPILER "/usr/bin/clang")
1819
SET (CMAKE_CXX_COMPILER "/usr/bin/clang++")
1920

20-
#set(MY_CMAKE_WARNING_FLAG " -Wall -Wextra -Wno-unused-parameter")
21-
#set(MY_CMAKE_WARNING_FLAG " -Wall -Wextra -Wno-unused-parameter -fsanitize=address -fno-omit-frame-pointer")
22-
#set(MY_CMAKE_WARNING_FLAG " -Wall -Wextra -Wno-unused-parameter -fno-omit-frame-pointer")
23-
set(MY_CMAKE_WARNING_FLAG " -Wall -Wextra -Wno-unused-parameter -fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer")
24-
#set(MY_CMAKE_WARNING_FLAG " -Wall -Wextra -Wno-unused-parameter")
25-
set(MY_CMAKE_POOL_FLAG " -DPOOL_TESTING -DUSE_VALGRIND")
26-
#set(MY_CMAKE_POOL_FLAG " -DPOOL_TESTING")
21+
## thread sanitizer
22+
#set (TSAN "1")
23+
IF(TSAN)
24+
set(MY_CMAKE_TSAN_FLAG " -DUSE_THREADCHECK -DDYNAMIC_ANNOTATIONS_ENABLED -fsanitize=thread -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/thread_sanitizer_blacklist")
25+
ELSE(TSAN)
26+
#set (ASAN "1")
27+
set(MY_CMAKE_TSAN_FLAG " ")
28+
ENDIF(TSAN)
2729

28-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_CMAKE_WARNING_FLAG} ${MY_CMAKE_POOL_FLAG}")
29-
#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${MY_CMAKE_WARNING_FLAG}")
30-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_CMAKE_WARNING_FLAG} ${MY_CMAKE_POOL_FLAG}")
31-
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MY_CMAKE_WARNING_FLAG}")
30+
## address sanitizer
31+
IF(ASAN)
32+
set(MY_CMAKE_ASAN_FLAG " -fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer")
33+
#-fsanitize-address-use-after-scope
34+
ELSE(ASAN)
35+
set(MY_CMAKE_ASAN_FLAG " ")
36+
ENDIF(ASAN)
37+
38+
set(MY_CMAKE_WARNING_FLAG " -Wall -Wextra -Wno-unused-parameter")
39+
40+
41+
#set(MY_CMAKE_POOL_FLAG " -DPOOL_TESTING -DUSE_VALGRIND")
42+
add_definitions(-DPOOL_TESTING)
43+
#add_definitions(-DLS_WORKCREW_DEBUG)
44+
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
45+
46+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_CMAKE_WARNING_FLAG} ${MY_CMAKE_TSAN_FLAG} ${MY_CMAKE_ASAN_FLAG}")
47+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_CMAKE_WARNING_FLAG} ${MY_CMAKE_TSAN_FLAG} ${MY_CMAKE_ASAN_FLAG}")
3248

3349

3450
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/src/config.h)
@@ -42,7 +58,6 @@ find_package(EXPAT REQUIRED)
4258

4359

4460
execute_process( COMMAND ${PROJECT_SOURCE_DIR}/dlossl.sh )
45-
execute_process( COMMAND ${PROJECT_SOURCE_DIR}/src/modules/pagespeed/dlpsol.sh )
4661

4762
##########################################################################################
4863
#If you want to link libUnitTest++, just un-comment out the following commands
@@ -67,11 +82,11 @@ add_definitions(-DUSE_IP2LOCATION)
6782

6883
add_definitions(-DTEST_OUTPUT_PLAIN_CONF)
6984
#add_definitions(-DLS_VG_DEBUG)
70-
#add_definitions(-DDEBUG_POOL)
85+
add_definitions(-DDEBUG_POOL)
7186
add_definitions(-DOPENSSL_NO_CXX)
7287

7388
execute_process( COMMAND getconf LFS_CFLAGS
74-
OUTPUT_VARIABLE LFS_CFLAGS )
89+
OUTPUT_VARIABLE LFS_CFLAGS )
7590

7691
add_definitions( ${LFS_CFLAGS} )
7792
add_definitions(-DUSE_UDNS)

addon/example/Makefile

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
LSIAPIDIR = /home/ron/Documents/litespeedtech/openlitespeed
2+
3+
CXX = clang++
4+
#CXX = g++-4.8
5+
CC = clang
6+
#CXXFLAGS = -std=c++11 -Wall -O0 -g
7+
#CXXFLAGS = -Wall -O0 -m32 -g -fno-inline -fno-omit-frame-pointer
8+
9+
# TODO: CXXFLAGS = -I $(LSIAPIDIR)/include -Wall -g -O0 -fPIC
10+
11+
#MY_CMAKE_TSAN_FLAG = -DUSE_THREADCHECK -DDYNAMIC_ANNOTATIONS_ENABLED -fsanitize=thread
12+
#MY_CMAKE_ASAN_FLAG = -fsanitize=address -fsanitize-recover=address -fno-omit-frame-pointer
13+
14+
CXXFLAGS = $(MY_CMAKE_ASAN_FLAG) $(MY_CMAKE_TSAN_FLAG) -I $(LSIAPIDIR)/src -I $(LSIAPIDIR)/include -Wall -g -fPIC -D_REENTRANT -Werror=return-type -Wno-comment -Wmissing-field-initializers
15+
16+
LDFLAGS = -lgd
17+
18+
19+
ifeq ($(UNAME_S),Darwin)
20+
CXXFLAGS += "-undefined dynamic_lookup"
21+
endif
22+
23+
CFLAGS = $(CXXFLAGS)
24+
25+
MODEXMPL_SRCS := $(wildcard *.c)
26+
27+
MODEXMPL_OBJS = $(MODEXMPL_SRCS:.c=.o)
28+
MODEXMPL_SOS = $(MODEXMPL_SRCS:.c=.so)
29+
30+
SRCS = $(MODEXMPL_SRCS);
31+
OBJS = $(MODEXMPL_OBJS);
32+
SOS = $(MODEXMPL_SOS);
33+
34+
all: $(SOS)
35+
36+
37+
-include make.Autodepend

addon/example/ccc.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ else
5858
fi
5959

6060

61-
gcc -g -Wall -fPIC -c -D_REENTRANT $(getconf LFS_CFLAGS) $TARGET.c -I "$LSIAPIDIR/src" -I "$LSIAPIDIR/include"
61+
gcc -g -Wall -fPIC -fvisibility=hidden -c -D_REENTRANT $(getconf LFS_CFLAGS) $TARGET.c -I "$LSIAPIDIR/src" -I "$LSIAPIDIR/include"
6262
gcc -g -Wall -fPIC $UNDEFINED_FLAG $(getconf LFS_CFLAGS) -o $TARGET.so $TARGET.o -shared $GDLIB
6363

6464
if [ -f $(pwd)/$TARGET.so ] ; then

addon/example/checksessionhooks.c

+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/*****************************************************************************
2+
* Open LiteSpeed is an open source HTTP server. *
3+
* Copyright (C) 2013 - 2015 LiteSpeed Technologies, Inc. *
4+
* *
5+
* This program is free software: you can redistribute it and/or modify *
6+
* it under the terms of the GNU General Public License as published by *
7+
* the Free Software Foundation, either version 3 of the License, or *
8+
* (at your option) any later version. *
9+
* *
10+
* This program is distributed in the hope that it will be useful, *
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13+
* GNU General Public License for more details. *
14+
* *
15+
* You should have received a copy of the GNU General Public License *
16+
* along with this program. If not, see http://www.gnu.org/licenses/. *
17+
*****************************************************************************/
18+
19+
#include "../include/ls.h"
20+
21+
#define MNAME checksessionhooks
22+
lsi_module_t MNAME;
23+
24+
/**
25+
* This module tests to make sure every session hook is reached.
26+
*/
27+
28+
const char *s_pCheckHookNames[LSI_HKPT_TOTAL_COUNT] =
29+
{
30+
"L4_BEGINSESSION",
31+
"L4_ENDSESSION",
32+
"L4_RECVING",
33+
"L4_SENDING",
34+
"HTTP_BEGIN",
35+
"RECV_REQ_HEADER",
36+
"URI_MAP",
37+
"HTTP_AUTH",
38+
"RECV_REQ_BODY",
39+
"RCVD_REQ_BODY",
40+
"RECV_RESP_HEADER",
41+
"RECV_RESP_BODY",
42+
"RCVD_RESP_BODY",
43+
"HANDLER_RESTART",
44+
"SEND_RESP_HEADER",
45+
"SEND_RESP_BODY",
46+
"HTTP_END",
47+
"MAIN_INITED",
48+
"MAIN_PREFORK",
49+
"MAIN_POSTFORK",
50+
"WORKER_POSTFORK",
51+
"WORKER_ATEXIT",
52+
"MAIN_ATEXIT"
53+
};
54+
55+
56+
int enableNextL4Hook(lsi_param_t *rec)
57+
{
58+
static int s_iL4Level = LSI_HKPT_L4_RECVING;
59+
g_api->log(NULL, LSI_LOG_DEBUG,
60+
"[Module:checkhttphooks] Try to enable level %s\n",
61+
s_pCheckHookNames[s_iL4Level]);
62+
g_api->enable_hook(rec->session, &MNAME, 1, &s_iL4Level, 1);
63+
if (s_iL4Level == LSI_HKPT_L4_ENDSESSION)
64+
{
65+
int disableHooks[] = { LSI_HKPT_L4_RECVING, LSI_HKPT_L4_SENDING };
66+
g_api->log(NULL, LSI_LOG_DEBUG,
67+
"[Module:checkhttphooks] All hooks enabled, "
68+
"disable L4 recv/send to prevent infinite loop.\n");
69+
g_api->enable_hook(rec->session, &MNAME, 0, disableHooks, 2);
70+
return 0;
71+
72+
}
73+
s_iL4Level++;
74+
if (s_iL4Level == LSI_HKPT_HTTP_BEGIN)
75+
s_iL4Level = LSI_HKPT_L4_ENDSESSION;
76+
return 0;
77+
}
78+
79+
80+
int enableNextHttpHook(lsi_param_t *rec)
81+
{
82+
static int s_iHttpLevel = LSI_HKPT_RCVD_REQ_HEADER;
83+
g_api->log(NULL, LSI_LOG_DEBUG,
84+
"[Module:checkhttphooks] Try to enable level %s\n",
85+
s_pCheckHookNames[s_iHttpLevel]);
86+
g_api->enable_hook(rec->session, &MNAME, 1, &s_iHttpLevel, 1);
87+
s_iHttpLevel++;
88+
// make sure to enable send resp header too, ignore req body.
89+
if (s_iHttpLevel == LSI_HKPT_RCVD_REQ_BODY
90+
|| s_iHttpLevel == LSI_HKPT_RCVD_RESP_HEADER
91+
|| s_iHttpLevel == LSI_HKPT_SEND_RESP_HEADER)
92+
{
93+
g_api->log(NULL, LSI_LOG_DEBUG,
94+
"[Module:checkhttphooks] Enable next level because "
95+
"%s may be skipped.\n", s_pCheckHookNames[s_iHttpLevel - 1]);
96+
enableNextHttpHook(rec);
97+
}
98+
return 0;
99+
}
100+
101+
102+
int skippedHook(lsi_param_t *rec)
103+
{
104+
g_api->log(NULL, LSI_LOG_DEBUG,
105+
"[Module:checkhttphooks] This level is generally skipped because "
106+
"it requires something else (e.g. a request body). "
107+
"This function shows that this level was enabled.\n");
108+
return 0;
109+
}
110+
111+
112+
int reachEnd(const char *pLevel)
113+
{
114+
g_api->log(NULL, LSI_LOG_DEBUG, "[Module:checkhttphooks] Reached the %s end!\n", pLevel);
115+
return 0;
116+
}
117+
118+
119+
int reachHttpEnd(lsi_param_t *rec) { return reachEnd("Http"); }
120+
int reachL4End(lsi_param_t *rec) { return reachEnd("L4"); }
121+
122+
static lsi_serverhook_t serverHooks[] =
123+
{
124+
{ LSI_HKPT_L4_BEGINSESSION, enableNextL4Hook, LSI_HOOK_NORMAL, LSI_FLAG_ENABLED},
125+
{ LSI_HKPT_L4_ENDSESSION, reachL4End, LSI_HOOK_NORMAL, 0},
126+
{ LSI_HKPT_L4_RECVING, enableNextL4Hook, LSI_HOOK_NORMAL, 0},
127+
{ LSI_HKPT_L4_SENDING, enableNextL4Hook, LSI_HOOK_NORMAL, 0},
128+
{ LSI_HKPT_HTTP_BEGIN, enableNextHttpHook, LSI_HOOK_NORMAL, LSI_FLAG_ENABLED},
129+
{ LSI_HKPT_RCVD_REQ_HEADER, enableNextHttpHook, LSI_HOOK_NORMAL, 0},
130+
{ LSI_HKPT_URI_MAP, enableNextHttpHook, LSI_HOOK_NORMAL, 0},
131+
{ LSI_HKPT_HTTP_AUTH, enableNextHttpHook, LSI_HOOK_NORMAL, 0},
132+
{ LSI_HKPT_RECV_REQ_BODY, skippedHook, LSI_HOOK_NORMAL, 0},
133+
{ LSI_HKPT_RCVD_REQ_BODY, skippedHook, LSI_HOOK_NORMAL, 0},
134+
{ LSI_HKPT_RCVD_RESP_HEADER, enableNextHttpHook, LSI_HOOK_NORMAL, 0},
135+
{ LSI_HKPT_RECV_RESP_BODY, enableNextHttpHook, LSI_HOOK_NORMAL, 0},
136+
{ LSI_HKPT_RCVD_RESP_BODY, enableNextHttpHook, LSI_HOOK_NORMAL, 0},
137+
{ LSI_HKPT_HANDLER_RESTART, skippedHook, LSI_HOOK_NORMAL, 0},
138+
{ LSI_HKPT_SEND_RESP_HEADER, enableNextHttpHook, LSI_HOOK_NORMAL, 0},
139+
{ LSI_HKPT_SEND_RESP_BODY, enableNextHttpHook, LSI_HOOK_NORMAL, 0},
140+
{ LSI_HKPT_HTTP_END, reachHttpEnd, LSI_HOOK_NORMAL, 0},
141+
LSI_HOOK_END //Must put this at the end position
142+
};
143+
144+
static int _init(lsi_module_t *pModule)
145+
{
146+
return 0;
147+
}
148+
149+
lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, _init, NULL, NULL,
150+
"checksessionhooks v1.0", serverHooks, {0}};
151+

addon/example/hellohandler.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ static int begin_process(const lsi_session_t *session)
3535

3636

3737
/**
38-
* Define a handler, need to provide a struct _handler_st object, in which
38+
* Define a handler, need to provide a lsi_reqhdlr_t object, in which
3939
* the first function pointer should not be NULL
4040
*/
41-
static lsi_reqhdlr_t myhandler = { begin_process, NULL, NULL, NULL };
42-
lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, NULL, &myhandler, NULL };
41+
static lsi_reqhdlr_t myhandler = { begin_process, NULL, NULL, NULL, NULL, NULL, NULL };
42+
LSMODULE_EXPORT lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, NULL, &myhandler, NULL, NULL, NULL, {0} };
4343

4444

addon/example/hellohandler2.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ static lsi_serverhook_t server_hooks[] =
7171
* Define a handler, need to provide a struct lsi_reqhdlr_t object, in which
7272
* the first function pointer should not be NULL
7373
*/
74-
static lsi_reqhdlr_t myhandler = { begin_process, NULL, NULL, NULL };
75-
lsi_module_t MNAME =
74+
static lsi_reqhdlr_t myhandler = { begin_process, NULL, NULL, NULL, NULL, NULL, NULL };
75+
LSMODULE_EXPORT lsi_module_t MNAME =
7676
{
77-
LSI_MODULE_SIGNATURE, init_module, &myhandler, NULL, "v1.0", server_hooks
77+
LSI_MODULE_SIGNATURE, init_module, &myhandler, NULL, "v1.0", server_hooks, {0}
7878
};

addon/example/imgresize.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <lsr/ls_loopbuf.h>
2121
#include <lsr/ls_xpool.h>
2222

23-
#include "gd.h"
23+
#include <gd.h>
2424
#include <stdio.h>
2525
#include <stdlib.h>
2626
#include <string.h>
@@ -269,7 +269,8 @@ static int init_module(lsi_module_t *pModule)
269269
return 0;
270270
}
271271

272-
lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, init_module, NULL, NULL, "imgresize", serverHooks};
272+
LSMODULE_EXPORT lsi_module_t MNAME = { LSI_MODULE_SIGNATURE, init_module, NULL,
273+
NULL, "imgresize", serverHooks, {0}};
273274

274275

275276

0 commit comments

Comments
 (0)