We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent aa1bbc5 commit 05bd1caCopy full SHA for 05bd1ca
1 file changed
http/server/HttpServer.cpp
@@ -296,12 +296,14 @@ std::shared_ptr<hv::EventLoop> HttpServer::loop(int idx) {
296
if (privdata == NULL) return NULL;
297
std::lock_guard<std::mutex> locker(privdata->mutex_);
298
if (privdata->loops.empty()) return NULL;
299
- if (idx >= 0 && idx < (int)privdata->loops.size()) {
300
- return privdata->loops[idx];
+ if (idx < 0) {
+ EventLoop* cur = currentThreadEventLoop;
301
+ for (auto& loop : privdata->loops) {
302
+ if (loop.get() == cur) return loop;
303
+ }
304
}
- EventLoop* cur = currentThreadEventLoop;
- for (auto& loop : privdata->loops) {
- if (loop.get() == cur) return loop;
305
+ else if (idx >= 0 && idx < (int)privdata->loops.size()) {
306
+ return privdata->loops[idx];
307
308
return NULL;
309
0 commit comments