Skip to content

Commit 468f5c8

Browse files
committed
Fix strict weak ordering requirements
1 parent 9c45399 commit 468f5c8

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/HttpRouter.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,13 @@ struct HttpRouter {
302302

303303
/* ANY method must be last, GET must be first */
304304
std::sort(root.children.begin(), root.children.end(), [](const auto &a, const auto &b) {
305-
/* Assuming the list of methods is unique, non-repeating */
306-
if (a->name == "GET") {
305+
if (a->name == "GET" && b->name != "GET") {
307306
return true;
308-
} else if (b->name == "GET") {
307+
} else if (b->name == "GET" && a->name != "GET") {
309308
return false;
310-
} else if (a->name == ANY_METHOD_TOKEN) {
309+
} else if (a->name == ANY_METHOD_TOKEN && b->name != ANY_METHOD_TOKEN) {
311310
return false;
312-
} else if (b->name == ANY_METHOD_TOKEN) {
311+
} else if (b->name == ANY_METHOD_TOKEN && a->name != ANY_METHOD_TOKEN) {
313312
return true;
314313
} else {
315314
return a->name < b->name;

tests/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ default:
55
./ChunkedEncoding
66
$(CXX) -std=c++17 -fsanitize=address TopicTree.cpp -o TopicTree
77
./TopicTree
8-
$(CXX) -std=c++17 -fsanitize=address HttpRouter.cpp -o HttpRouter
8+
$(CXX) -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -std=c++17 -fsanitize=address HttpRouter.cpp -o HttpRouter
99
./HttpRouter
1010
$(CXX) -std=c++17 -fsanitize=address BloomFilter.cpp -o BloomFilter
1111
./BloomFilter

0 commit comments

Comments
 (0)