diff --git a/ryzom/server/src/frontend_service/quic_transceiver.cpp b/ryzom/server/src/frontend_service/quic_transceiver.cpp index f41206fcf9..6398c4d8ca 100644 --- a/ryzom/server/src/frontend_service/quic_transceiver.cpp +++ b/ryzom/server/src/frontend_service/quic_transceiver.cpp @@ -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: { @@ -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); diff --git a/ryzom/server/src/frontend_service/quic_transceiver.h b/ryzom/server/src/frontend_service/quic_transceiver.h index 57dcd5b8fe..bf925c34cb 100644 --- a/ryzom/server/src/frontend_service/quic_transceiver.h +++ b/ryzom/server/src/frontend_service/quic_transceiver.h @@ -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(); };