2017-09-22 21:00:03 +00:00
|
|
|
# Copyright (c) 2017 LiteSpeed Technologies Inc. See LICENSE.
|
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
|
|
|
|
|
|
|
|
project(lsquic)
|
|
|
|
|
2018-03-12 22:25:01 +00:00
|
|
|
IF (NOT (CMAKE_C_COMPILER MATCHES "MSVC"))
|
2017-09-22 21:00:03 +00:00
|
|
|
# We prefer clang
|
|
|
|
IF(NOT ("${CMAKE_C_COMPILER}" MATCHES "ccc-analyzer" OR
|
|
|
|
"${CMAKE_C_COMPILER}" MATCHES "gcc" OR
|
|
|
|
"${CMAKE_C_COMPILER}" MATCHES "afl-gcc"))
|
|
|
|
FIND_PROGRAM(CLANG "clang")
|
|
|
|
IF(CLANG)
|
|
|
|
SET(CMAKE_C_COMPILER "${CLANG}")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
2018-03-12 22:25:01 +00:00
|
|
|
ENDIF()
|
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
# By default, we compile in development mode. To compile production code,
|
|
|
|
# pass -DDEVEL_MODE=0 to cmake (before that, `make clean' and remove any
|
|
|
|
# cmake cache files).
|
|
|
|
#
|
|
|
|
IF(NOT DEFINED DEVEL_MODE)
|
|
|
|
SET(DEVEL_MODE 1)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
MESSAGE(STATUS "DEVEL_MODE: ${DEVEL_MODE}")
|
|
|
|
|
2018-03-12 22:25:01 +00:00
|
|
|
IF (NOT (CMAKE_C_COMPILER MATCHES "MSVC"))
|
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wall -Wextra -Wno-unused-parameter")
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fno-omit-frame-pointer")
|
|
|
|
|
2017-09-26 15:26:05 +00:00
|
|
|
IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.3)
|
2017-09-22 21:00:03 +00:00
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wno-missing-field-initializers")
|
|
|
|
ENDIF()
|
|
|
|
IF(DEVEL_MODE EQUAL 1)
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -O0 -g3")
|
|
|
|
# -Werror is used to force us to fix warnings early.
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Werror")
|
|
|
|
IF(CMAKE_C_COMPILER MATCHES "clang")
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fsanitize=address")
|
|
|
|
ENDIF()
|
|
|
|
# Uncomment to enable fault injection testing via libfiu:
|
|
|
|
#SET (MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DFIU_ENABLE=1")
|
|
|
|
#SET (FIULIB "fiu")
|
|
|
|
ELSE()
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -O3 -g0")
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DNDEBUG")
|
|
|
|
# Comment out the following line to compile out debug messages:
|
|
|
|
#SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_LOWEST_LOG_LEVEL=LSQ_LOG_INFO")
|
|
|
|
ENDIF()
|
|
|
|
|
2017-09-29 15:18:32 +00:00
|
|
|
IF(LSQUIC_PROFILE EQUAL 1)
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -g -pg")
|
|
|
|
ENDIF()
|
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
IF(MY_CMAKE_FLAGS MATCHES "fsanitize=address")
|
|
|
|
MESSAGE(STATUS "AddressSanitizer is ON")
|
|
|
|
ELSE()
|
|
|
|
MESSAGE(STATUS "AddressSanitizer is OFF")
|
|
|
|
ENDIF()
|
|
|
|
|
2018-03-12 22:25:01 +00:00
|
|
|
#MSVC
|
|
|
|
ELSE()
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -W4 -WX -Zi -DWIN32_LEAN_AND_MEAN -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS -I${CMAKE_CURRENT_SOURCE_DIR}/wincompat")
|
|
|
|
IF(DEVEL_MODE EQUAL 1)
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Od ")
|
|
|
|
#SET (MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DFIU_ENABLE=1")
|
|
|
|
#SET (FIULIB "fiu")
|
|
|
|
ELSE()
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -OX")
|
|
|
|
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DNDEBUG")
|
|
|
|
# Comment out the following line to compile out debug messages:
|
|
|
|
#SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLSQUIC_LOWEST_LOG_LEVEL=LSQ_LOG_INFO")
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
SET (BORINGSSL_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/../boringssl/include)
|
|
|
|
SET (VCPKG_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/../vcpkg/installed/x64-windows-static/include )
|
|
|
|
|
|
|
|
IF(CMAKE_BUILD_TYPE MATCHES "Debug")
|
|
|
|
SET (BORINGSSL_LIB ${CMAKE_CURRENT_SOURCE_DIR}/../boringssl/build/ssl ${CMAKE_CURRENT_SOURCE_DIR}/../boringssl/build/x64/debug)
|
|
|
|
SET (VCPKG_LIB ${CMAKE_CURRENT_SOURCE_DIR}/../vcpkg/installed/x64-windows-static/lib)
|
|
|
|
SET (ZLIB_NAME "zlibd")
|
|
|
|
ELSE()
|
|
|
|
SET (BORINGSSL_LIB ${CMAKE_CURRENT_SOURCE_DIR}/../boringssl/build/ssl ${CMAKE_CURRENT_SOURCE_DIR}/../boringssl/build/x64)
|
|
|
|
SET (VCPKG_LIB ${CMAKE_CURRENT_SOURCE_DIR}/../vcpkg/installed/x64-windows-static/debug/lib)
|
|
|
|
SET (ZLIB_NAME zlibd)
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
ENDIF() #MSVC
|
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_CMAKE_FLAGS} $ENV{EXTRA_CFLAGS}")
|
|
|
|
|
|
|
|
MESSAGE(STATUS "Compiler flags: ${CMAKE_C_FLAGS}")
|
|
|
|
|
2017-09-26 15:26:05 +00:00
|
|
|
IF(NOT DEFINED BORINGSSL_INCLUDE)
|
2017-09-27 16:01:07 +00:00
|
|
|
SET(BORINGSSL_INCLUDE /usr/local/include)
|
2017-09-26 15:26:05 +00:00
|
|
|
ENDIF()
|
|
|
|
IF(NOT DEFINED BORINGSSL_LIB)
|
2017-09-27 16:01:07 +00:00
|
|
|
SET(BORINGSSL_LIB /usr/local/lib)
|
2017-09-26 15:26:05 +00:00
|
|
|
ENDIF()
|
2017-09-22 21:00:03 +00:00
|
|
|
|
2018-03-12 22:25:01 +00:00
|
|
|
|
|
|
|
include_directories(${BORINGSSL_INCLUDE} ${VCPKG_INCLUDE} )
|
|
|
|
link_directories( ${BORINGSSL_LIB} ${VCPKG_LIB} )
|
2017-09-27 16:01:07 +00:00
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
include_directories( include )
|
|
|
|
|
|
|
|
IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
|
|
|
# Find libevent on FreeBSD:
|
|
|
|
include_directories( /usr/local/include )
|
|
|
|
link_directories( /usr/local/lib )
|
|
|
|
ENDIF()
|
|
|
|
|
2018-03-12 22:25:01 +00:00
|
|
|
IF (NOT (CMAKE_C_COMPILER MATCHES "MSVC"))
|
Latest changes
- [API Change] Sendfile-like functionality is gone. The stream no
longer opens files and deals with file descriptors. (Among other
things, this makes the code more portable.) Three writing functions
are provided:
lsquic_stream_write
lsquic_stream_writev
lsquic_stream_writef (NEW)
lsquic_stream_writef() is given an abstract reader that has function
pointers for size() and read() functions which the user can implement.
This is the most flexible way. lsquic_stream_write() and
lsquic_stream_writev() are now both implemented as wrappers around
lsquic_stream_writef().
- [OPTIMIZATION] When writing to stream, be it within or without the
on_write() callback, place data directly into packet buffer,
bypassing auxiliary data structures. This reduces amount of memory
required, for the amount of data that can be written is limited
by the congestion window.
To support writes outside the on_write() callback, we keep N
outgoing packet buffers per connection which can be written to
by any stream. One half of these are reserved for the highest
priority stream(s), the other half for all other streams. This way,
low-priority streams cannot write instead of high-priority streams
and, on the other hand, low-priority streams get a chance to send
their packets out.
The algorithm is as follows:
- When user writes to stream outside of the callback:
- If this is the highest priority stream, place it onto the
reserved N/2 queue or fail.
(The actual size of this queue is dynamic -- MAX(N/2, CWND) --
rather than N/2, allowing high-priority streams to write as
much as can be sent.)
- If the stream is not the highest priority, try to place the
data onto the reserved N/2 queue or fail.
- When tick occurs *and* more packets can be scheduled:
- Transfer packets from the high N/2 queue to the scheduled
queue.
- If more scheduling is allowed:
- Call on_write callbacks for highest-priority streams,
placing resulting packets directly onto the scheduled queue.
- If more scheduling is allowed:
- Transfer packets from the low N/2 queue to the scheduled
queue.
- If more scheduling is allowed:
- Call on_write callbacks for non-highest-priority streams,
placing resulting packets directly onto the scheduled queue
The number N is currently 20, but it could be varied based on
resource usage.
- If stream is created due to incoming headers, make headers readable
from on_new.
- Outgoing packets are no longer marked non-writeable to prevent placing
more than one STREAM frame from the same stream into a single packet.
This property is maintained via code flow and an explicit check.
Packets for stream data are allocated using a special function.
- STREAM frame elision is cheaper, as we only perform it if a reset
stream has outgoing packets referencing it.
- lsquic_packet_out_t is smaller, as stream_rec elements are now
inside a union.
2017-10-31 13:35:58 +00:00
|
|
|
add_executable(http_client
|
|
|
|
test/http_client.c
|
|
|
|
test/prog.c
|
|
|
|
test/test_common.c
|
|
|
|
)
|
2017-09-26 15:26:05 +00:00
|
|
|
target_link_libraries(http_client lsquic event pthread libssl.a libcrypto.a ${FIULIB} z m)
|
2018-03-12 22:25:01 +00:00
|
|
|
ELSE()
|
|
|
|
add_executable(http_client
|
|
|
|
test/http_client.c
|
|
|
|
test/prog.c
|
|
|
|
wincompat/test_common_win.c
|
|
|
|
wincompat/getopt.c
|
|
|
|
wincompat/getopt1.c
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(http_client lsquic event ssl crypto ${FIULIB} ${ZLIB_NAME} ws2_32)
|
|
|
|
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
|
|
|
|
add_subdirectory(src)
|
|
|
|
|
2018-02-26 21:01:16 +00:00
|
|
|
add_subdirectory(test)
|
2017-09-22 21:00:03 +00:00
|
|
|
|
2018-02-28 19:25:21 +00:00
|
|
|
IF(DEVEL_MODE EQUAL 1)
|
|
|
|
# Our test framework relies on assertions, only compile if assertions are
|
|
|
|
# enabled.
|
|
|
|
#
|
|
|
|
enable_testing()
|
|
|
|
ENDIF()
|
|
|
|
|
2017-09-22 21:00:03 +00:00
|
|
|
|
|
|
|
ADD_CUSTOM_TARGET(docs doxygen dox.cfg)
|