Skip to content

Commit

Permalink
Auto PR from release/0.7 to main (#309)
Browse files Browse the repository at this point in the history
* Mute an UBSan check error for SCOPED_LOCK macro (#283)

* io: support reset photon at fork (#282)

In photon context, event engine based module need reset after
fork, if exec will not be called after fork.
This is implicitly done by pthread_atfork hook.

Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com>

* RPC support graceful shutdown

* fs: support xattr for extfs and subfs (#298)

Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com>

* Sequential mutex (#294)

seq_mutex

* exit(0) requires stdlib.h (#303)

* fix e2fs include dir name (#301)

Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com>

* [feat] http client with cert

Signed-off-by: zhuangbowei.zbw <zhuangbowei.zbw@alibaba-inc.com>

* minor fix for std-compat (#307)

* minor fix for std-compat

* rpc::string add empty method

* set io_uring eventfd non-blocking

---------

Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com>
Signed-off-by: zhuangbowei.zbw <zhuangbowei.zbw@alibaba-inc.com>
Co-authored-by: Bob Chen <beef9999@qq.com>
Co-authored-by: yuchen0cc <91253032+yuchen0cc@users.noreply.github.com>
Co-authored-by: Huiba Li <lihuiba@gmail.com>
Co-authored-by: zhuangbowei.zbw <zhuangbowei.zbw@alibaba-inc.com>
Co-authored-by: Lanzheng Liu <lanzheng.liulz@alibaba-inc.com>
  • Loading branch information
6 people committed Dec 18, 2023
1 parent 767b3fb commit 4513104
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
7 changes: 3 additions & 4 deletions examples/sync-primitive/sync-primitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct Message {
std::chrono::time_point<std::chrono::steady_clock> start;
};

static const int num_producers = 16, num_consumers = 16;
static const int num_producers = 8, num_consumers = 8;
static LockfreeMPMCRingQueue<Message*, 1024 * 1024> ring;
static std::atomic<uint64_t> qps{0}, latency{0};

Expand Down Expand Up @@ -90,7 +90,7 @@ int main() {
Message message;
ring.push(&message);
{
std::unique_lock l(message.mu);
std::unique_lock<std::mutex> l(message.mu);
message.cv.wait(l, [&] { return message.done; });
}
auto end = std::chrono::steady_clock::now();
Expand All @@ -117,7 +117,7 @@ int main() {
m->sem.signal(1);
#else
{
std::unique_lock l(m->mu);
std::unique_lock<std::mutex> l(m->mu);
m->done = true;
m->cv.notify_one();
}
Expand All @@ -128,7 +128,6 @@ int main() {

// Show QPS and latency
photon::thread_create11([&] {
photon::init(photon::INIT_EVENT_DEFAULT, photon::INIT_IO_NONE);
while (true) {
photon::thread_sleep(1);
auto prev_qps = qps.exchange(0, std::memory_order_seq_cst);
Expand Down
8 changes: 3 additions & 5 deletions io/iouring-wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class iouringEngine : public MasterEventEngine, public CascadingEventEngine, pub
}
}

m_eventfd = eventfd(0, EFD_CLOEXEC);
m_eventfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
if (m_eventfd < 0) {
LOG_ERRNO_RETURN(0, -1, "iouring: failed to create eventfd");
}
Expand Down Expand Up @@ -285,10 +285,8 @@ class iouringEngine : public MasterEventEngine, public CascadingEventEngine, pub
if (ret < 0) {
return errno == ETIMEDOUT ? 0 : -1;
}
uint64_t value = 0;
if (eventfd_read(m_eventfd, &value)) {
LOG_ERROR("iouring: error reading cascading event fd, `", ERRNO());
}
uint64_t value;
eventfd_read(m_eventfd, &value);

// Reap events
size_t num = 0;
Expand Down
1 change: 1 addition & 0 deletions rpc/serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ namespace rpc
const T& operator[](long i) const { return ((T*)_ptr)[i]; }
const T& front() const { return (*this)[0]; }
const T& back() const { return (*this)[(long)size() - 1]; }
bool empty() const { return _len == 0; }
void assign(const T* x, size_t size) { buffer::assign(x, sizeof(*x) * size); }
void assign(const std::vector<T>& vec) { assign(&vec[0], vec.size()); }

Expand Down
3 changes: 2 additions & 1 deletion thread/std-compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,10 @@ class unique_lock {
}

Mutex* release() noexcept {
auto* mu = m_mutex;
m_mutex = nullptr;
m_owns = false;
return m_mutex;
return mu;
}

Mutex* mutex() const noexcept {
Expand Down

0 comments on commit 4513104

Please sign in to comment.