From 5e93fa78fba99d5c2b01fbb349c413a66d03515c Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Tue, 7 Jan 2025 23:16:46 +0800 Subject: [PATCH] feat reformat CMakeLists.txt --- CMakeLists.txt | 60 ++++++++--------------------- tile/rpc/http_handler.h | 8 ++++ tile/rpc/protocol/http/buffer_io.cc | 17 +++++--- 3 files changed, 37 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a164210..2055a8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,24 +7,20 @@ set(tile_VERSION_BUILD $ENV{CI_STEP_NUMBER}) if(NOT tile_VERSION_BUILD) set(tile_VERSION_BUILD "0") endif() -set(TILE_VERSION - "${tile_VERSION_MAJOR}.${tile_VERSION_MINOR}.${tile_VERSION_PATCH}.${tile_VERSION_BUILD}" -) + project( tile VERSION "${tile_VERSION_MAJOR}.${tile_VERSION_MINOR}.${tile_VERSION_PATCH}" LANGUAGES C CXX) +set(TILE_VERSION "${PROJECT_VERSION}.${tile_VERSION_BUILD}") + set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_POSITION_INDEPENDENT_CODE ON) -# add static libgcc and libstdc++ for static linking set(CMAKE_C_FLAGS -# "${CMAKE_C_FLAGS} -static-libgcc -static-libstdc++") set(CMAKE_CXX_FLAGS -# "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++") - option(TILE_BUILD_TESTS "Build tests" OFF) option(TILE_BUILD_BENCHMARKS "Build tests" OFF) option(TILE_WITH_OPENSSL "Build wih openssl" OFF) @@ -95,39 +91,17 @@ set(gflags_DIR "${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags") # add_subdirectory("third_party/context") set(CURL_DISABLE_TESTS ON) -set(CURL_CA_PATH - "none" - CACHE STRING "" FORCE) -set(CURL_ENABLE_SSL - OFF - CACHE BOOL "" FORCE) -set(USE_LIBIDN2 - OFF - CACHE BOOL "" FORCE) -set(CURL_USE_LIBPSL - OFF - CACHE BOOL "" FORCE) -set(CURL_USE_LIBSSH - OFF - CACHE BOOL "" FORCE) -set(CURL_USE_LIBSSH2 - OFF - CACHE BOOL "" FORCE) -set(CURL_USE_GSSAPI - OFF - CACHE BOOL "" FORCE) -set(CURL_USE_RTMP - OFF - CACHE BOOL "" FORCE) -set(USE_OPENSSL_QUIC - OFF - CACHE BOOL "" FORCE) -set(USE_MSH3 - OFF - CACHE BOOL "" FORCE) -set(CURL_DISABLE_LDAP - ON - CACHE BOOL "" FORCE) +set(CURL_CA_PATH "none" CACHE STRING "" FORCE) +set(CURL_ENABLE_SSL OFF CACHE BOOL "" FORCE) +set(USE_LIBIDN2 OFF CACHE BOOL "" FORCE) +set(CURL_USE_LIBPSL OFF CACHE BOOL "" FORCE) +set(CURL_USE_LIBSSH OFF CACHE BOOL "" FORCE) +set(CURL_USE_LIBSSH2 OFF CACHE BOOL "" FORCE) +set(CURL_USE_GSSAPI OFF CACHE BOOL "" FORCE) +set(CURL_USE_RTMP OFF CACHE BOOL "" FORCE) +set(USE_OPENSSL_QUIC OFF CACHE BOOL "" FORCE) +set(USE_MSH3 OFF CACHE BOOL "" FORCE) +set(CURL_DISABLE_LDAP ON CACHE BOOL "" FORCE) set(ZLIB_FOUND ON) set(ZLIB_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib") set(ZLIB_LIBRARIES zlib) @@ -331,7 +305,7 @@ if(TILE_BUILD_TESTS) tile_add_test(${TEST_NAME} ${SRC_FILE}) endforeach() - endfunction(add_test_group) + endfunction() add_test_group(${CMAKE_CURRENT_SOURCE_DIR}/tile/system system) add_test_group(${CMAKE_CURRENT_SOURCE_DIR}/tile/base base) @@ -340,7 +314,7 @@ if(TILE_BUILD_TESTS) add_test_group(${CMAKE_CURRENT_SOURCE_DIR}/tile/net net) add_test_group(${CMAKE_CURRENT_SOURCE_DIR}/tile/rpc rpc) tile_add_custom_test("custom_http_client_test" "tests/http_client_test.cc") -endif(TILE_BUILD_TESTS) +endif() if(TILE_BUILD_BENCHMARKS) add_subdirectory("third_party/benchmark") @@ -366,4 +340,4 @@ if(TILE_BUILD_BENCHMARKS) tile_add_bm(base_internal_time_keeper_benchmark "tile/base/internal/time_keeper_benchmark.cc") tile_add_bm(base_chrono_benchmark "tile/base/chrono_benchmark.cc") -endif(TILE_BUILD_BENCHMARKS) +endif() diff --git a/tile/rpc/http_handler.h b/tile/rpc/http_handler.h index e69de29..aab938d 100644 --- a/tile/rpc/http_handler.h +++ b/tile/rpc/http_handler.h @@ -0,0 +1,8 @@ +#ifndef TILE_RPC_HTTP_HANDLER_H +#define TILE_RPC_HTTP_HANDLER_H + +#pragma once + +#include + +#endif// TILE_RPC_HTTP_HANDLER_H diff --git a/tile/rpc/protocol/http/buffer_io.cc b/tile/rpc/protocol/http/buffer_io.cc index 275e647..2487de2 100644 --- a/tile/rpc/protocol/http/buffer_io.cc +++ b/tile/rpc/protocol/http/buffer_io.cc @@ -54,14 +54,20 @@ EasyDetectHttp(const void *data, std::size_t length) } std::size_t -DetermineHeaderSizeFast(const char *const ptr, std::size_t limit) +DetermineHeaderSizeFast(const char *const ptr, std::size_t length) { - auto ep = ptr + limit; - auto p = ptr + 1; + char *first_end_pos = (char *) memmem(ptr, length, "\r\n\r\n", 4); + + if (first_end_pos == NULL) { return -1; } + return first_end_pos + 4 - ptr; + + /* + auto end_ptr = ptr + length; + auto p = ptr + 1; while (true) { // First '\n' in '\r\n\r\n' - p = static_cast(memchr(const_cast(p), '\n', ep - p)); - if (TILE_UNLIKELY(p == nullptr || ep - p < 3)) { return -1; } + p = static_cast(memchr(const_cast(p), '\n', end_ptr - p)); + if (TILE_UNLIKELY(p == nullptr || end_ptr - p < 3)) { return -1; } if (p[2] == '\n') { TILE_CHECK_GE(p - 1, ptr); @@ -73,6 +79,7 @@ DetermineHeaderSizeFast(const char *const ptr, std::size_t limit) } ++p; } + */ } }// namespace