Commit 3500c37
authored
[PSL-1229] pasteld: handle keep-alive connections (#260)
* [PSL-1229] pasteld: handle keep-alive connections
pasteld v2.2.6
Added separate class to keep information about HTTP Connection.
Now requests coming from the existing keep-alive http connection create
only HTTPRequest object without connection info.
HTTPRequest object lifetime is now limited to http_request_cb callback.
Save http connections only in unordered_map with client socket as a key (CHttpWorkerContext).
- added accept error handler.
- improved logging
other changes:
- returned c++20/gcc-11 changes for Linux
- added Ctrl-C console handler for Windows to shutdown pasteld
- improved shutdown when pasteld is still in initialization mode (added some checks to exit earlier)
* pasteld v2.2.6-beta2:
- fixed race condition on accepting new connections
* pasteld v2.2.6-beta3
Enhanced the synchronization and notification handling mechanisms in the CHttpWorkerContext class to prevent potential race conditions, ensure robust operation of the event loop, avoid indefinite waits that could lead to deadlocks, and handle potential failures of event_base_loopbreak.
Key Changes:
- Condition Variable Notifications:
Replaced m_LoopCond.notify_one() with m_LoopCond.notify_all() to ensure that all waiting threads are notified of changes to the event loop state.
This is critical in scenarios where multiple threads might be waiting for the same condition.
- Mutex Locking During Notification:
Ensured that m_LoopMutex is locked while calling m_LoopCond.notify_all().
This prevents race conditions by ensuring that notifications and state changes are properly synchronized.
- Timed Wait for Condition Variable:
Changed the indefinite wait on m_LoopCond.wait to a timed wait using m_LoopCond.wait_for.
This avoids the risk of threads waiting indefinitely, which can lead to deadlocks, and allows periodic checks for the event loop state and shutdown conditions.
- Handling Potential Failures of event_base_loopbreak:
Added logic to repeatedly call event_base_loopbreak in a loop to ensure that the event base loop actually exits, handling cases where event_base_loopbreak might fail on the first call.1 parent c18a517 commit 3500c37
File tree
5 files changed
+45
-4
lines changed- src
5 files changed
+45
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
129 | 132 | | |
130 | 133 | | |
131 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
719 | 721 | | |
720 | 722 | | |
721 | 723 | | |
| 724 | + | |
722 | 725 | | |
723 | 726 | | |
724 | 727 | | |
| |||
768 | 771 | | |
769 | 772 | | |
770 | 773 | | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
771 | 780 | | |
| 781 | + | |
772 | 782 | | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
773 | 790 | | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
774 | 797 | | |
775 | 798 | | |
776 | 799 | | |
| |||
833 | 856 | | |
834 | 857 | | |
835 | 858 | | |
836 | | - | |
837 | | - | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
838 | 872 | | |
839 | 873 | | |
840 | 874 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
185 | 189 | | |
186 | 190 | | |
187 | 191 | | |
| |||
0 commit comments