Skip to content

Commit 53caf1b

Browse files
committed
Update to build 20; fixed client->server messages
Fixed bug with reading messages when messagereader::getremaining() is called. Fixed kicking clients when a client->server message with no data (beside subchannel/variant) was sent; server was mistakenly set to not accept empty messages, and due to it seeing a message corruption, it kicked the client immediately. Fixed crash caused by lock being freed twice during some message parsing errors. Also switched kicks for broken messages from clean exit to immediate exit. It may not be safe to wait for connection to finish processing, as client could be pouring messages into their end.
1 parent f50a5fb commit 53caf1b

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

Lacewing/Lacewing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,7 @@ namespace lacewing {
18471847
struct relayserverinternal;
18481848
struct relayserver
18491849
{
1850-
static const int buildnum = 19;
1850+
static const int buildnum = 20;
18511851

18521852
void * internaltag, * tag = nullptr;
18531853

Lacewing/MessageReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class messagereader
115115
return this->buffer;
116116

117117
std::string_view remaining(this->buffer + offset, bytesleft());
118-
offset += size;
118+
offset += remaining.size();
119119

120120
if (!allowempty && (remaining.empty() || !remaining.front()))
121121
failed = true;

Lacewing/RelayServer.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,7 +1715,7 @@ bool relayserverinternal::client_messagehandler(std::shared_ptr<relayserver::cli
17151715
cliReadLock.lw_unlock();
17161716

17171717
const lw_ui8 subchannel = reader.get <lw_ui8> ();
1718-
std::string_view message3 = reader.getremaining(false);
1718+
std::string_view message3 = reader.getremaining();
17191719

17201720
if (reader.failed)
17211721
{
@@ -1948,14 +1948,15 @@ bool relayserverinternal::client_messagehandler(std::shared_ptr<relayserver::cli
19481948

19491949
if (!trustedClient)
19501950
{
1951-
// LW_ESCALATION_NOTE
1952-
// auto cliWriteLock = cliReadLock.lw_upgrade();
19531951
client->_readonly = true;
19541952

1955-
cliReadLock.lw_unlock();
1953+
// LW_ESCALATION_NOTE
1954+
// auto cliWriteLock = cliReadLock.lw_upgrade();
1955+
if (cliReadLock.isEnabled())
1956+
cliReadLock.lw_unlock();
19561957
auto cliWriteLock = client->lock.createWriteLock();
19571958

1958-
client->socket->close(); // TODO: Should be immediate?
1959+
client->socket->close(true); // immediate disconnect
19591960
}
19601961

19611962
// only return false if socket is emergency closing and

0 commit comments

Comments
 (0)