Commit graph

25 commits

Author SHA1 Message Date
Robert Müller 22352316d8 Give jobpool worker threads different names based on index 2023-10-15 22:10:50 +02:00
Robert Müller 2dcec6496f Use std::vector for jobpool threads
To simplify the usage and to support an arbitrary number of threads.
2023-10-15 22:00:25 +02:00
heinrich5991 406bc261fb
Merge pull request #6958 from Zwelf/pr-fix-crash-dnsbl
Fix stack overflow in destructor when dnsbl object is kept too long alive
2023-08-01 09:40:04 +00:00
Zwelf d682d24eb5 Fix stack overflow in destructor when dnsbl object is kept too long alive
`shared_ptr`s of `CServer::m_pDnsblLookup[ClientID]` are set, but not
cleaned up when done. Therefore the Job is kept alive until the player
disconnects and a new player joins on that slot. Currently this means
that the full linked list of jobs is kept alive.

When the Job is overwritten with a new job, all the remaining objects in
the list can be dropped. With enough jobs, that is causing a stack
overflow in the destructor.

This patch fixes this overflow by making the lifetime independent of the
previous Job. Jobs can get dropped after processing them, even when the
previous job is still alive.

Fixes #6954
2023-08-01 11:14:53 +02:00
heinrich5991 c5e27b283b Delete fishy-looking assignment operator/copy constructor of IJob
Since they're not called anyway, they can go away.
2023-08-01 09:45:15 +02:00
Dennis Felsing 51909c19ab Add CLockScope
Remove unused lock and scope in threading.h

Not sure if this is preferred

We could also try switching to std::mutex
2022-06-03 12:21:23 +02:00
Jupeyy 0ff8054b6c Allow more precise Destroy call to Job pool 2022-03-12 13:52:13 +01:00
Dennis Felsing 18d9997348 Fix clang-format 2022-02-15 00:32:04 +01:00
Dennis Felsing b58470fda4 Add modernize-use-equals-default 2022-02-15 00:17:57 +01:00
heinrich5991 11adc8c1ff Make it possible to run jobs in the current thread 2021-05-13 03:15:18 +02:00
def 3be8a592e5 Run clang-format
Purely automatic change. In case of conflict with this change, apply the
other change and rerun the formatting to restore it:

$ python scripts/fix_style.py
2020-09-26 21:50:15 +02:00
def 1e4890c499 More error checking in system.c (fixes #1317) 2019-03-19 23:16:29 +01:00
heinrich5991 36694d3852 Add a way to call for external moderator help
This is done by HTTP POSTing to a location specified by
`sv_modhelp_url`. We also provide a `src/modhelp/server.py` which can
use theses POSTs to forward them to Discord servers.

The POST contains a JSON object payload, with the keys `"port"` which
contains the server port, `"player_id"` which contains the calling
player's client ID, `"player_name"` which contains the calling player's
nick and `"message"` which is the user-specified message.

Make JSON-escaping function public, add tests and fix bugs uncovered by
these tests.

Supersedes #1129.
2018-06-19 23:27:35 +02:00
heinrich5991 3f43624d21 Add a couple of tests for CJobPool 2017-11-24 10:33:42 +01:00
heinrich5991 94acac91a0 Overhauled job system
The engine now takes `std::shared_ptr<IJob>`, this will ensure the
appropriate lifetime of the given parameters, it also allows for proper
destruction. Remove the now obsolete `IFetcher` interface and `CFetcher`
class.

Also adds some locks to `CUpdater`, previously it didn't have any locks
at all.
2017-11-23 15:47:38 +01:00
Learath2 b8b4f7771d Rename the callback 2017-10-19 18:13:28 +02:00
Learath 96acddb57f Fix the other use after free 2017-10-17 15:39:20 +02:00
def e64e59a839 semaphore instead of busy waiting in CJobPool 2017-09-02 12:30:55 +02:00
def 705349f2e5 Clean up and fix semaphores and threading 2017-08-31 19:18:07 +02:00
HMH d3714f7efa close workerthreads on shutdown 2017-07-21 15:52:42 +02:00
def db2256e827 Fix a few whitespace-at-end-of-file issues 2015-08-22 15:27:41 +02:00
def 3992b1346b Hopefully fix compilation on new OS X systems
Names collided with some new OS X defined names, fixes #189
2015-04-07 19:07:38 +02:00
oy 06115dd49d added "Whitespace and line Endings cleanup" by GreYFoX 2011-04-13 20:37:12 +02:00
Sworddragon fc9211c777 Updated copyrights 2010-11-20 21:26:06 +01:00
Magnus Auvinen 72c06a2589 copied refactor to trunk 2010-05-29 07:25:38 +00:00