mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-29 10:39:28 -05:00
server: Added thread check to protect writedata
This commit is contained in:
@@ -69,6 +69,12 @@ bool cmEventBasedConnection::IsOpen() const
|
|||||||
|
|
||||||
void cmEventBasedConnection::WriteData(const std::string& _data)
|
void cmEventBasedConnection::WriteData(const std::string& _data)
|
||||||
{
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
|
auto curr_thread_id = uv_thread_self();
|
||||||
|
assert(this->Server);
|
||||||
|
assert(uv_thread_equal(&curr_thread_id, &this->Server->ServeThreadId));
|
||||||
|
#endif
|
||||||
|
|
||||||
auto data = _data;
|
auto data = _data;
|
||||||
assert(this->WriteStream);
|
assert(this->WriteStream);
|
||||||
if (BufferStrategy) {
|
if (BufferStrategy) {
|
||||||
|
|||||||
@@ -436,6 +436,12 @@ bool cmServerBase::StartServeThread()
|
|||||||
|
|
||||||
bool cmServerBase::Serve(std::string* errorMessage)
|
bool cmServerBase::Serve(std::string* errorMessage)
|
||||||
{
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
|
uv_thread_t blank_thread_t = {};
|
||||||
|
assert(uv_thread_equal(&blank_thread_t, &ServeThreadId));
|
||||||
|
ServeThreadId = uv_thread_self();
|
||||||
|
#endif
|
||||||
|
|
||||||
errorMessage->clear();
|
errorMessage->clear();
|
||||||
|
|
||||||
uv_signal_init(&Loop, &this->SIGINTHandler);
|
uv_signal_init(&Loop, &this->SIGINTHandler);
|
||||||
|
|||||||
@@ -67,6 +67,15 @@ protected:
|
|||||||
bool ServeThreadRunning = false;
|
bool ServeThreadRunning = false;
|
||||||
uv_thread_t ServeThread;
|
uv_thread_t ServeThread;
|
||||||
uv_async_t ShutdownSignal;
|
uv_async_t ShutdownSignal;
|
||||||
|
#ifndef NDEBUG
|
||||||
|
public:
|
||||||
|
// When the server starts it will mark down it's current thread ID,
|
||||||
|
// which is useful in other contexts to just assert that operations
|
||||||
|
// are performed on that same thread.
|
||||||
|
uv_thread_t ServeThreadId = {};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
#endif
|
||||||
|
|
||||||
uv_loop_t Loop;
|
uv_loop_t Loop;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user