Skip to content

Commit 225f4d4

Browse files
authored
[rdma]Fix some rdma bugs (#973)
1 parent 1981587 commit 225f4d4

File tree

23 files changed

+590
-429
lines changed

23 files changed

+590
-429
lines changed

.clang-format

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,4 @@ AllowShortIfStatementsOnASingleLine: Never
1111
Language: JavaScript
1212
DisableFormat: true
1313
---
14-
# Ignore json file
15-
Language: Json
16-
DisableFormat: true
17-
---
18-
Language: Proto
19-
DisableFormat: true
14+

cmake/develop.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ if(ENABLE_SANITIZER AND NOT MSVC)
5050
endif()
5151
else()
5252
## address santizer
53-
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
53+
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
5454
check_asan(HAS_ASAN)
5555
if(HAS_ASAN)
5656
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")

include/ylt/coro_io/client_pool.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class client_pool : public std::enable_shared_from_this<
194194
co_await coro_io::sleep_for(wait_time, &client->get_executor());
195195
self = watcher.lock();
196196
++i;
197-
} while (i < self->pool_config_.connect_retry_count);
197+
} while (self && i < self->pool_config_.connect_retry_count);
198198
ELOG_WARN << "reconnect client{" << client.get() << "},host:{"
199199
<< client->get_host() << ":" << client->get_port()
200200
<< "} out of max limit, stop retry. connect failed";
@@ -220,7 +220,7 @@ class client_pool : public std::enable_shared_from_this<
220220
co_return;
221221
}
222222
auto executor = self->io_context_pool_.get_executor();
223-
auto client = std::make_unique<client_t>(*executor);
223+
auto client = std::make_unique<client_t>(executor);
224224
if (!client->init_config(client_config))
225225
AS_UNLIKELY {
226226
ELOG_ERROR << "Init client config failed in host alive detect. That "
@@ -271,7 +271,7 @@ class client_pool : public std::enable_shared_from_this<
271271
if (client == nullptr) {
272272
std::unique_ptr<client_t> cli;
273273
auto executor = io_context_pool_.get_executor();
274-
client = std::make_unique<client_t>(*executor);
274+
client = std::make_unique<client_t>(executor);
275275
if (!client->init_config(client_config))
276276
AS_UNLIKELY {
277277
ELOG_ERROR << "init client config failed.";
@@ -298,8 +298,10 @@ class client_pool : public std::enable_shared_from_this<
298298
this->weak_from_this(), clients,
299299
(std::max)(collect_time, std::chrono::milliseconds{50}),
300300
pool_config_.idle_queue_per_max_clear_count)
301-
.directlyStart([](auto&&) {
302-
},coro_io::get_global_executor());
301+
.directlyStart(
302+
[](auto&&) {
303+
},
304+
coro_io::get_global_executor());
303305
}
304306
}
305307
}

include/ylt/coro_io/coro_io.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,18 @@ dispatch(Func func, Executor executor) {
240240
co_return co_await awaitor.await_resume(helper);
241241
}
242242

243+
template <typename Executor>
244+
inline async_simple::coro::Lazy<async_simple::Try<void>> dispatch(
245+
Executor executor) {
246+
if (executor.running_in_this_thread()) {
247+
co_return async_simple::Try<void>{};
248+
}
249+
co_return co_await dispatch(
250+
[]() {
251+
},
252+
executor);
253+
}
254+
243255
namespace detail {
244256

245257
template <typename T>

include/ylt/coro_io/detail/client_queue.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,14 @@ class client_queue {
6363
}
6464
bool try_dequeue(client_t& c) {
6565
const int_fast16_t index = selected_index_;
66-
if (size_[index ^ 1]) {
67-
if (queue_[index ^ 1].try_dequeue(c)) {
68-
--size_[index ^ 1];
69-
return true;
70-
}
71-
}
7266
if (queue_[index].try_dequeue(c)) {
7367
--size_[index];
7468
return true;
7569
}
70+
if (queue_[index ^ 1].try_dequeue(c)) {
71+
--size_[index ^ 1];
72+
return true;
73+
}
7674
return false;
7775
}
7876
std::size_t clear_old(std::size_t max_clear_cnt) {

0 commit comments

Comments
 (0)