Skip to content

Commit

Permalink
Improved thread locks on Windows
Browse files Browse the repository at this point in the history
Changed server thread locks to improve multithreading - work still to do though.
This is mostly MMF2Exts fixes; bluewing-cpp-server doesn't have UI so it doesn't need a separate processing thread as MMF2Exts uses it. However, it can have two writer threads, due to the ping timer thread.
The new lock system has separate locks for server client list, server channel list, server udp and a meta lock (for host/unhost, welcome message change, handler change).

Amended SSL client struct type, as well.

This should be official server build 34.
  • Loading branch information
SortaCore committed Jan 23, 2023
1 parent 6f0cd1d commit 74c169e
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 77 deletions.
9 changes: 8 additions & 1 deletion Lacewing/Lacewing.h
Original file line number Diff line number Diff line change
Expand Up @@ -2141,7 +2141,14 @@ struct relayserver
// Expects you have already checked channel with that name does not exist.
std::shared_ptr<relayserver::channel> createchannel(std::string_view channelName, std::shared_ptr<lacewing::relayserver::client> master, bool hidden, bool autoclose);

mutable lacewing::readwritelock lock;
// handles unhost/host, welcome message change, handler change
mutable lacewing::readwritelock lock_meta;
// handles channel list modifications - only to the underlying vector, not to requests like leave or close requests
mutable lacewing::readwritelock lock_channellist;
// handles client list modifications - only to the underlying vector, not to requests like disconnect requests
mutable lacewing::readwritelock lock_clientlist;
// handles UDP?
mutable lacewing::readwritelock lock_udp;

typedef void(*handler_connect) (lacewing::relayserver &server, std::shared_ptr<lacewing::relayserver::client> client);
typedef void(*handler_disconnect) (lacewing::relayserver &server, std::shared_ptr<lacewing::relayserver::client> client);
Expand Down
1 change: 1 addition & 0 deletions Lacewing/PhiAddress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ void LacewingFatalErrorMsgBox2(const char * const func, const char * const file,
err << "Lacewing fatal error detected.\nFile: "sv << fileSub << "\nFunction: "sv << func << "\nLine: "sv << line;
#ifdef _WIN32
MessageBoxA(NULL, err.str().c_str(), "" PROJECT_NAME " fatal error", MB_ICONERROR);
std::abort();
#else
char output[512];
strcpy(output, err.str().c_str());
Expand Down
Loading

0 comments on commit 74c169e

Please sign in to comment.