Skip to content

Commit

Permalink
Notify main thread of user disconnections
Browse files Browse the repository at this point in the history
  • Loading branch information
kaetemi committed Feb 24, 2023
1 parent f20e74f commit 37b2127
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ryzom/server/src/frontend_service/quic_transceiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,12 @@ _Function_class_(QUIC_CONNECTION_CALLBACK)
break;
case QUIC_CONNECTION_EVENT_SHUTDOWN_INITIATED_BY_TRANSPORT:
nlinfo("Shutdown initiated by transport");
self->shutdownReceived(user);
status = QUIC_STATUS_SUCCESS;
break;
case QUIC_CONNECTION_EVENT_SHUTDOWN_INITIATED_BY_PEER:
nlinfo("Shutdown initiated by peer");
self->shutdownReceived(user);
status = QUIC_STATUS_SUCCESS;
break;
case QUIC_CONNECTION_EVENT_SHUTDOWN_COMPLETE: {
Expand Down Expand Up @@ -502,6 +504,21 @@ void CQuicTransceiver::datagramReceived(CQuicUserContext *user, const uint8 *buf
}
}

void CQuicTransceiver::shutdownReceived(CQuicUserContext *user)
{
// Increase reference for FIFO copy
user->increaseRef();

// Locked block
{
CAtomicFlagLockYield lock(m->BufferMutex);
static const uint8 removeEvent = TReceivedMessage::RemoveClient;
static_assert(MsgHeaderSize == sizeof(removeEvent));
m->Buffer->push(&removeEvent, MsgHeaderSize);
m->Buffer->push((uint8 *)&user, sizeof(user)); // Pointer
}
}

NLMISC::CBufFIFO *CQuicTransceiver::swapWriteQueue(NLMISC::CBufFIFO *writeQueue)
{
CAtomicFlagLockYield lock(m->BufferMutex);
Expand Down
3 changes: 3 additions & 0 deletions ryzom/server/src/frontend_service/quic_transceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ class CQuicTransceiver
/// Received datagram
void datagramReceived(CQuicUserContext *user, const uint8 *buffer, uint32 length);

/// Received shutdown
void shutdownReceived(CQuicUserContext *user);

/// Generates a token address to identify the connection with existing code
NLNET::CInetAddress generateTokenAddr();
};
Expand Down

0 comments on commit 37b2127

Please sign in to comment.