Skip to content

Commit

Permalink
release 0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
beef9999 committed Dec 6, 2022
1 parent 8429e8a commit 1db359d
Show file tree
Hide file tree
Showing 43 changed files with 2,910 additions and 2,623 deletions.
21 changes: 9 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ option(ENABLE_URING "enable io_uring function" OFF)
option(ENABLE_FUSE "enable fuse function" OFF)
option(ENABLE_SASL "enable sasl" OFF)
option(ENABLE_MIMIC_VDSO "enable mimic vdso" OFF)
option(BUILD_TESTING "enable build testing" OFF)

# Get CPU arch
execute_process(COMMAND uname -m OUTPUT_VARIABLE ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
Expand All @@ -40,7 +41,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE on)
if (${ARCH} STREQUAL x86_64)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2")
elseif (${ARCH} STREQUAL aarch64)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=generic+crc -fsigned-char")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=generic+crc -fsigned-char -fno-stack-protector")
endif ()

check_cxx_compiler_flag(-mcrc32 COMPILER_HAS_MCRC32_FLAG)
Expand All @@ -57,6 +58,12 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()

# If ccache exists, use it to speed up compiling
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
endif(CCACHE_FOUND)

# CMake dirs
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/output)
Expand Down Expand Up @@ -104,15 +111,6 @@ if (ENABLE_SASL)
find_package(gsasl REQUIRED)
endif ()

# Fetch boost
FetchContent_Declare(
boost
URL https://boostorg.jfrog.io/artifactory/main/release/1.75.0/source/boost_1_75_0.tar.gz
URL_MD5 38813f6feb40387dfe90160debd71251
)
FetchContent_MakeAvailable(boost)
set(boost_include_dir ${boost_SOURCE_DIR})

# Compile photon objects
file(GLOB PHOTON_SRC
photon.cpp
Expand All @@ -138,7 +136,6 @@ file(GLOB PHOTON_SRC
net/security-context/tls-stream.cpp
rpc/*.cpp
thread/*.cpp
thread/switch_context_${ARCH}.s
)
if (APPLE)
list(APPEND PHOTON_SRC io/kqueue.cpp)
Expand All @@ -156,7 +153,7 @@ if (ENABLE_SASL)
endif ()

add_library(photon_obj OBJECT ${PHOTON_SRC})
target_include_directories(photon_obj PUBLIC include ${boost_include_dir} ${OPENSSL_INCLUDE_DIR})
target_include_directories(photon_obj PUBLIC include ${OPENSSL_INCLUDE_DIR})
target_compile_definitions(photon_obj PRIVATE _FILE_OFFSET_BITS=64 FUSE_USE_VERSION=29)
if (ENABLE_URING)
target_include_directories(photon_obj PUBLIC ${liburing_include_dir})
Expand Down
2 changes: 1 addition & 1 deletion common/checksum/crc32c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ __attribute__((constructor)) static void crc_init() {
}

#if (defined(__aarch64__) && defined(__ARM_FEATURE_CRC32))
#ifdef __APPLE__
#if (defined(__clang__))
#define _crc32di __builtin_arm_crc32cd
#define _crc32qi __builtin_arm_crc32cb
#else
Expand Down
9 changes: 8 additions & 1 deletion common/identity-pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,23 @@ IdentityPoolBase::~IdentityPoolBase()
{
if (autoscale)
disable_autoscale();

bool logged = false;
{
SCOPED_LOCK(m_mtx);
while (m_refcnt > 0) {
LOG_DEBUG("IdentityPool is still in use, wait to destruct");
m_cvar.wait(m_mtx, 10 * 1000 * 1000);
if (m_refcnt > 0) {
LOG_WARN("IdentityPool is still in use! Waiting for destruction.");
logged = true;
}
}
}
assert(m_size <= m_capacity);
while (m_size > 0)
m_dtor(m_items[--m_size]);
if (logged)
LOG_WARN("IdentityPool destructed");
}

struct ScalePoolController;
Expand Down
1 change: 1 addition & 0 deletions fs/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
#include <cerrno>
#include <cstdarg>
#include <sys/uio.h> // struct iovec
#include <sys/time.h> // struct timeval
#include <photon/common/stream.h>

#define UNIMPLEMENTED(func) \
Expand Down
28 changes: 14 additions & 14 deletions fs/httpfs/httpfs_v2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ class HttpFs_v2 : public fs::IFileSystem {
uint64_t m_conn_timeout;
uint64_t m_stat_timeout;

net::Client *m_client;
net::http::Client *m_client;

public:
HttpFs_v2(bool default_https, uint64_t conn_timeout, uint64_t stat_timeout)
: m_default_https(default_https),
m_conn_timeout(conn_timeout),
m_stat_timeout(stat_timeout) {
m_client = net::new_http_client();
m_client = net::http::new_http_client();
}
~HttpFs_v2() {
delete m_client;
}
net::Client* get_client() { return m_client; }
net::http::Client* get_client() { return m_client; }
IFile* open(const char* pathname, int flags) override;
IFile* open(const char* pathname, int flags, mode_t) override {
return open(pathname, flags);
Expand Down Expand Up @@ -95,7 +95,7 @@ class HttpFs_v2 : public fs::IFileSystem {
class HttpFile_v2 : public fs::VirtualReadOnlyFile {
public:
std::string m_url;
net::CommonHeaders<> m_common_header;
net::http::CommonHeaders<> m_common_header;
HttpFs_v2* m_fs;
struct stat m_stat;
uint64_t m_stat_gettime = 0;
Expand Down Expand Up @@ -123,7 +123,7 @@ class HttpFile_v2 : public fs::VirtualReadOnlyFile {
m_stat_timeout(stat_timeout),
m_url_param(param) {}

int update_stat_from_resp(const net::Client::Operation* op) {
int update_stat_from_resp(const net::http::Client::Operation* op) {
auto ret = op->status_code;
m_stat_gettime = photon::now;
m_authorized = (ret >= 0 && ret != 401 && ret != 403);
Expand All @@ -139,15 +139,15 @@ class HttpFile_v2 : public fs::VirtualReadOnlyFile {
m_stat.st_size = len;
return 0;
}
void send_read_request(net::Client::Operation &op, off_t offset, size_t length, const Timeout &tmo) {
void send_read_request(net::http::Client::Operation &op, off_t offset, size_t length, const Timeout &tmo) {
again:
estring url;
url.appends(m_url, "?", m_url_param);
op.req.reset(net::Verb::GET, url);
op.req.reset(net::http::Verb::GET, url);
op.set_enable_proxy(m_fs->get_client()->has_proxy());
op.req.merge_headers(m_common_header);
op.req.insert_range(offset, offset + length - 1);
op.req.content_length(0);
op.req.headers.merge(m_common_header);
op.req.headers.range(offset, offset + length - 1);
op.req.headers.content_length(0);
op.timeout = tmo.timeout();
m_fs->get_client()->call(&op);
if (op.status_code < 0) {
Expand All @@ -159,7 +159,7 @@ class HttpFile_v2 : public fs::VirtualReadOnlyFile {
goto again;
}
}
using HTTP_OP = net::Client::OperationOnStack<64 * 1024 - 1>;
using HTTP_OP = net::http::Client::OperationOnStack<64 * 1024 - 1>;
int refresh_stat() {
Timeout tmo(m_conn_timeout);
HTTP_OP op;
Expand Down Expand Up @@ -196,7 +196,7 @@ class HttpFile_v2 : public fs::VirtualReadOnlyFile {
VALUE(m_url), VALUE(offset), VALUE(ret));
}
m_authorized = true;
ret = op.resp_body->readv(iovec, iovcnt);
ret = op.resp.readv(iovec, iovcnt);
return ret;
}

Expand Down Expand Up @@ -250,8 +250,8 @@ IFile* HttpFs_v2::open(const char* pathname, int flags) {

if (pathname[0] == '/') ++pathname;
estring_view fn(pathname), prefix;
if (0 == net::what_protocol(fn))
prefix = net::http_or_s(!m_default_https);
if (0 == net::http::what_protocol(fn))
prefix = net::http::http_or_s(!m_default_https);

std::string_view param;
auto pos = fn.find_first_of('?');
Expand Down
1 change: 0 additions & 1 deletion include/photon/net/http/field.h

This file was deleted.

1 change: 1 addition & 0 deletions include/photon/net/http/message.h
1 change: 0 additions & 1 deletion include/photon/net/http/parser.h

This file was deleted.

Loading

0 comments on commit 1db359d

Please sign in to comment.