Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions .github/workflows/ci.linux.arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: [self-hosted, Linux, ARM64]

container:
image: dokken/centos-stream-8:sha-40294ce
image: ghcr.io/coldwings/photon-ut-base:latest
options: --cpus 4

steps:
Expand All @@ -23,14 +23,14 @@ jobs:

- uses: actions/checkout@v3

- name: Install Dependencies
run: |
dnf install -y git gcc-c++ cmake 'dnf-command(config-manager)'
dnf install -y gcc-toolset-9-gcc-c++
dnf install -y openssl-devel libcurl-devel libaio-devel
dnf install -y epel-release
dnf config-manager --set-enabled powertools
dnf install -y gtest-devel gmock-devel gflags-devel fuse-devel libgsasl-devel e2fsprogs-devel
# - name: Install Dependencies
# run: |
# dnf install -y git gcc-c++ cmake 'dnf-command(config-manager)'
# dnf install -y gcc-toolset-9-gcc-c++
# dnf install -y openssl-devel libcurl-devel libaio-devel
# dnf install -y epel-release
# dnf config-manager --set-enabled powertools
# dnf install -y gtest-devel gmock-devel gflags-devel fuse-devel libgsasl-devel e2fsprogs-devel

- name: Build
run: |
Expand All @@ -51,7 +51,7 @@ jobs:
runs-on: [self-hosted, Linux, ARM64]

container:
image: dokken/centos-stream-8:sha-40294ce
image: ghcr.io/coldwings/photon-ut-base:latest
options: --cpus 4

steps:
Expand All @@ -63,14 +63,14 @@ jobs:

- uses: actions/checkout@v3

- name: Install Dependencies
run: |
dnf install -y git gcc-c++ cmake 'dnf-command(config-manager)'
dnf install -y gcc-toolset-9-gcc-c++
dnf install -y openssl-devel libcurl-devel libaio-devel
dnf install -y epel-release
dnf config-manager --set-enabled powertools
dnf install -y gtest-devel gmock-devel gflags-devel fuse-devel libgsasl-devel e2fsprogs-devel
# - name: Install Dependencies
# run: |
# dnf install -y git gcc-c++ cmake 'dnf-command(config-manager)'
# dnf install -y gcc-toolset-9-gcc-c++
# dnf install -y openssl-devel libcurl-devel libaio-devel
# dnf install -y epel-release
# dnf config-manager --set-enabled powertools
# dnf install -y gtest-devel gmock-devel gflags-devel fuse-devel libgsasl-devel e2fsprogs-devel

- name: Build
run: |
Expand Down
52 changes: 26 additions & 26 deletions .github/workflows/ci.linux.x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: [self-hosted, Linux, X64]

container:
image: dokken/centos-stream-8:sha-40294ce
image: ghcr.io/coldwings/photon-ut-base:latest
options: --cpus 4

steps:
Expand All @@ -23,14 +23,14 @@ jobs:

- uses: actions/checkout@v3

- name: Install Dependencies
run: |
dnf install -y git gcc-c++ cmake 'dnf-command(config-manager)'
dnf install -y gcc-toolset-9-gcc-c++
dnf install -y openssl-devel libcurl-devel libaio-devel
dnf install -y epel-release
dnf config-manager --set-enabled powertools
dnf install -y gtest-devel gmock-devel gflags-devel fuse-devel libgsasl-devel e2fsprogs-devel
# - name: Install Dependencies
# run: |
# dnf install -y git gcc-c++ cmake 'dnf-command(config-manager)'
# dnf install -y gcc-toolset-9-gcc-c++
# dnf install -y openssl-devel libcurl-devel libaio-devel
# dnf install -y epel-release
# dnf config-manager --set-enabled powertools
# dnf install -y gtest-devel gmock-devel gflags-devel fuse-devel libgsasl-devel e2fsprogs-devel

- name: Build
run: |
Expand All @@ -51,7 +51,7 @@ jobs:
runs-on: [self-hosted, Linux, X64]

container:
image: dokken/centos-stream-8:sha-40294ce
image: ghcr.io/coldwings/photon-ut-base:latest
options: --cpus 4

steps:
Expand All @@ -63,14 +63,14 @@ jobs:

- uses: actions/checkout@v3

- name: Install Dependencies
run: |
dnf install -y git gcc-c++ cmake 'dnf-command(config-manager)'
dnf install -y gcc-toolset-9-gcc-c++
dnf install -y openssl-devel libcurl-devel libaio-devel
dnf install -y epel-release
dnf config-manager --set-enabled powertools
dnf install -y gtest-devel gmock-devel gflags-devel fuse-devel libgsasl-devel e2fsprogs-devel
# - name: Install Dependencies
# run: |
# dnf install -y git gcc-c++ cmake 'dnf-command(config-manager)'
# dnf install -y gcc-toolset-9-gcc-c++
# dnf install -y openssl-devel libcurl-devel libaio-devel
# dnf install -y epel-release
# dnf config-manager --set-enabled powertools
# dnf install -y gtest-devel gmock-devel gflags-devel fuse-devel libgsasl-devel e2fsprogs-devel

- name: Build
run: |
Expand All @@ -91,7 +91,7 @@ jobs:
runs-on: [self-hosted, Linux, X64]

container:
image: dokken/centos-stream-8:sha-40294ce
image: ghcr.io/coldwings/photon-ut-base:latest
# In order to run io_uring, the docker daemon should add --default-ulimit memlock=-1:-1
options: --cpus 4

Expand All @@ -104,13 +104,13 @@ jobs:

- uses: actions/checkout@v3

- name: Install Dependencies
run: |
dnf install -y git gcc-c++ cmake
dnf install -y gcc-toolset-9-gcc-c++
dnf install -y openssl-devel libcurl-devel
dnf install -y epel-release
dnf install -y fuse-devel libgsasl-devel e2fsprogs-devel
# - name: Install Dependencies
# run: |
# dnf install -y git gcc-c++ cmake
# dnf install -y gcc-toolset-9-gcc-c++
# dnf install -y openssl-devel libcurl-devel
# dnf install -y epel-release
# dnf install -y fuse-devel libgsasl-devel e2fsprogs-devel

- name: Build
run: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci.macos.arm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@

jobs:
macOS-clang-debug:
runs-on: [self-hosted, macOS, ARM64]
runs-on: macos-14

steps:
# - uses: szenius/[email protected]
# with:
# timezoneLinux: "Asia/Shanghai"
# timezoneMacos: "Asia/Shanghai"
# timezoneWindows: "China Standard Time"
- uses: szenius/[email protected]
with:
timezoneLinux: "Asia/Shanghai"
timezoneMacos: "Asia/Shanghai"
timezoneWindows: "China Standard Time"

- uses: actions/checkout@v3

- name: Install Dependencies
shell: bash
run: |
brew install cmake openssl gflags googletest gsasl

- name: Build
run: |
cmake -B ${{github.workspace}}/build -D PHOTON_BUILD_TESTING=ON -D CMAKE_BUILD_TYPE=Debug \
-D PHOTON_ENABLE_SASL=ON -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@3
cmake --build ${{github.workspace}}/build -j -- VERBOSE=1

- name: Test
working-directory: ${{github.workspace}}/build
run: ctest --timeout 3600 -V

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
25 changes: 14 additions & 11 deletions common/alog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,23 +204,26 @@ void LogFormatter::put_integer_dec(ALogBuffer& buf, ALogInteger x)
}

__attribute__((constructor)) static void __initial_timezone() { tzset(); }
static time_t dayid = 0;
static time_t dayid = 0, minuteid = 0, tsdelta = 0;
static struct tm alog_time = {0};
struct tm* alog_update_time(time_t now)
{
auto now0 = now;
struct tm* alog_update_time(time_t now0) {
auto now = now0 + tsdelta;
int sec = now % 60; now /= 60;
if (unlikely(now != minuteid)) { // calibrate wall time every minute
now = time(0) - timezone;
tsdelta = now - now0;
sec = now % 60; now /= 60;
minuteid = now;
}
int min = now % 60; now /= 60;
int hor = now % 24; now /= 24;
if (now != dayid)
{
if (unlikely(now != dayid)) {
dayid = now;
gmtime_r(&now0, &alog_time);
auto now_ = now0 + tsdelta;
gmtime_r(&now_, &alog_time);
alog_time.tm_year+=1900;
alog_time.tm_mon++;
}
else
{
} else {
alog_time.tm_sec = sec;
alog_time.tm_min = min;
alog_time.tm_hour = hor;
Expand Down Expand Up @@ -499,7 +502,7 @@ LogBuffer& operator << (LogBuffer& log, const Prologue& pro)
auto t = &alog_time;
#else
auto ts = photon::alog_update_now();
auto t = alog_update_time(ts.tv_sec - timezone);
auto t = alog_update_time(ts.tv_sec);
#endif
log.printf(t->tm_year, '/');
log.printf(DEC_W2P0(t->tm_mon), '/');
Expand Down
5 changes: 3 additions & 2 deletions common/enumerable.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ struct Enumerable
{
T* obj;
explicit iterator(T* obj) : obj(obj) {
if (obj && obj->next() < 0)
if (obj && !obj->valid())
this->obj = nullptr;
}
using R = typename std::result_of<decltype(&T::get)(T)>::type;
R operator*() { return obj->get(); }
R operator*() { return obj ? obj->get() : R{}; }
bool operator==(const iterator& rhs) const { return obj == rhs.obj; }
bool operator!=(const iterator& rhs) const { return !(*this == rhs); }
iterator& operator++()
Expand Down Expand Up @@ -92,6 +92,7 @@ inline void __example_of_enumerable__()
{
struct exam
{
bool valid() { return false; }
int next() { return -1; } // move to next, return 0 for success, -1 for failure
double* get() { return nullptr; } // get current result
};
Expand Down
2 changes: 1 addition & 1 deletion common/estring.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class estring_view : public std::string_view
}
iterator& operator++()
{
_part = _host->find_part(_part.end());
_part = _host->find_part(_part.end() + 1);
return *this;
}
iterator& operator++(int)
Expand Down
28 changes: 8 additions & 20 deletions common/lockfree_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class LockfreeMPMCRingQueue : public LockfreeRingQueueBase<T, N> {
using Base::empty;
using Base::full;

bool push_weak(const T& x) {
bool push(const T& x) {
auto t = tail.load(std::memory_order_acquire);
for (;;) {
auto& slot = slots[idx(t)];
Expand All @@ -192,15 +192,16 @@ class LockfreeMPMCRingQueue : public LockfreeRingQueueBase<T, N> {
}
} else {
auto const prevTail = t;
auto h = head.load(std::memory_order_acquire);
t = tail.load(std::memory_order_acquire);
if (t == prevTail) {
if (t == prevTail && Base::check_full(h, t)) {
return false;
}
}
}
}

bool pop_weak(T& x) {
bool pop(T& x) {
auto h = head.load(std::memory_order_acquire);
for (;;) {
auto& slot = slots[idx(h)];
Expand All @@ -213,28 +214,15 @@ class LockfreeMPMCRingQueue : public LockfreeRingQueueBase<T, N> {
}
} else {
auto const prevHead = h;
auto t = tail.load(std::memory_order_acquire);
h = head.load(std::memory_order_acquire);
if (h == prevHead) {
if (h == prevHead && Base::check_empty(h, t)) {
return false;
}
}
}
}

bool push(const T& x) {
do {
if (push_weak(x)) return true;
} while (!full());
return false;
}

bool pop(T& x) {
do {
if (pop_weak(x)) return true;
} while (!empty());
return false;
}

template <typename Pause = ThreadPause>
void send(const T& x) {
static_assert(std::is_base_of<PauseBase, Pause>::value,
Expand Down Expand Up @@ -536,8 +524,8 @@ namespace common {
* and load balancing.
* Watch out that `recv` should run in photon environment (because it has to)
* use photon semaphore to be notified that new item has sended. `send` could
* running in photon or std::thread environment (needs to set template `Pause` as
* `ThreadPause`).
* running in photon or std::thread environment (needs to set template `Pause`
* as `ThreadPause`).
*
* @tparam QueueType shoulde be one of LockfreeMPMCRingQueue,
* LockfreeBatchMPMCRingQueue, or LockfreeSPSCRingQueue, with their own template
Expand Down
5 changes: 3 additions & 2 deletions fs/localfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,9 @@ namespace fs
virtual dirent* get() override
{
if (direntp) {
memcpy(&m_dirent, direntp, sizeof(m_dirent));
return &m_dirent;
memcpy(&m_dirent, direntp,
std::min(sizeof(m_dirent), (size_t)direntp->d_reclen));
return &m_dirent;
}
return direntp;
}
Expand Down
Loading
Loading