mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-15 02:29:10 +00:00
Fix: race-condition when quitting the game with libcurl
There could be a callback in _new_http_callbacks that is not processed yet. All callbacks in _http_callbacks were cancelled, but not the ones in _new_http_callbacks
This commit is contained in:
@@ -278,10 +278,9 @@ void NetworkHTTPUninitialize()
|
|||||||
{
|
{
|
||||||
_http_thread_exit = true;
|
_http_thread_exit = true;
|
||||||
|
|
||||||
/* Queues must be cleared (and the queue CV signalled) after _http_thread_exit is set to ensure that the HTTP thread can exit */
|
/* Ensure the callbacks are handled. This is mostly needed as we send
|
||||||
for (auto &callback : _http_callbacks) {
|
* a survey just before close, and that might be pending here. */
|
||||||
callback->ClearQueue();
|
NetworkHTTPSocketHandler::HTTPReceive();
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(_http_mutex);
|
std::lock_guard<std::mutex> lock(_http_mutex);
|
||||||
|
@@ -97,20 +97,6 @@ public:
|
|||||||
return this->queue.empty();
|
return this->queue.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear everything in the queue.
|
|
||||||
*
|
|
||||||
* Should be called from the Game Thread.
|
|
||||||
*/
|
|
||||||
void ClearQueue()
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lock(this->mutex);
|
|
||||||
|
|
||||||
this->queue.clear();
|
|
||||||
this->queue_cv.notify_all();
|
|
||||||
}
|
|
||||||
|
|
||||||
HTTPThreadSafeCallback(HTTPCallback *callback) : callback(callback) {}
|
HTTPThreadSafeCallback(HTTPCallback *callback) : callback(callback) {}
|
||||||
|
|
||||||
~HTTPThreadSafeCallback()
|
~HTTPThreadSafeCallback()
|
||||||
|
Reference in New Issue
Block a user