diff --git a/nel/include/nel/misc/buf_fifo.h b/nel/include/nel/misc/buf_fifo.h index 50da6e030f..3cb26ceed6 100644 --- a/nel/include/nel/misc/buf_fifo.h +++ b/nel/include/nel/misc/buf_fifo.h @@ -76,6 +76,7 @@ class CBufFIFO /// Concate and push 'buffer1' and buffer2 in the head of the FIFO. The goal is to avoid a copy void push (const std::vector &buffer1, const std::vector &buffer2); + void push (const uint8 *buffer1, uint32 size1, const uint8 *buffer2, uint32 size2); /// Get the buffer in the tail of the FIFO and put it in 'buffer' void front (std::vector &buffer); diff --git a/nel/src/misc/buf_fifo.cpp b/nel/src/misc/buf_fifo.cpp index 691ca79405..6291de7398 100644 --- a/nel/src/misc/buf_fifo.cpp +++ b/nel/src/misc/buf_fifo.cpp @@ -120,18 +120,23 @@ void CBufFIFO::push (const uint8 *buffer, uint32 s) } void CBufFIFO::push(const std::vector &buffer1, const std::vector &buffer2) +{ + push(&buffer1[0], buffer1.size(), &buffer2[0], buffer2.size()); +} + +void CBufFIFO::push(const uint8 *buffer1, uint32 size1, const uint8 *buffer2, uint32 size2) { #if STAT_FIFO TTicks before = CTime::getPerformanceTime(); #endif - TFifoSize s = (TFifoSize)(buffer1.size() + buffer2.size()); + TFifoSize s = (TFifoSize)(size1 + size2); #if DEBUG_FIFO nldebug("%p push2(%d)", this, s); #endif - nlassert((buffer1.size() + buffer2.size ()) > 0 && (buffer1.size() + buffer2.size ()) < pow(2.0, static_cast(sizeof(TFifoSize)*8))); + nlassert((size1 + size2) > 0 && (size1 + size2) < pow(2.0, static_cast(sizeof(TFifoSize)*8))); // avoid too big fifo if (this->size() > 10000000) @@ -157,8 +162,8 @@ void CBufFIFO::push(const std::vector &buffer1, const std::vector _Head += sizeof(TFifoSize); // store the block itself - CFastMem::memcpy(_Head, &(buffer1[0]), buffer1.size()); - CFastMem::memcpy(_Head + buffer1.size(), &(buffer2[0]), buffer2.size()); + CFastMem::memcpy(_Head, &(buffer1[0]), size1); + CFastMem::memcpy(_Head + size1, &(buffer2[0]), size2); _Head += s; _Empty = false; diff --git a/ryzom/client/src/network_connection.cpp b/ryzom/client/src/network_connection.cpp index 12d53ff433..1c48c5abee 100644 --- a/ryzom/client/src/network_connection.cpp +++ b/ryzom/client/src/network_connection.cpp @@ -1231,6 +1231,7 @@ bool CNetworkConnection::stateLogin() sendSystemLogin(); _LatestLoginTime = _UpdateTime; // Time out the login after 24 attempts (every 300ms, so after 7.2 seconds) +#if 1 // Disable login timeout here when debugging login messages if (m_LoginAttempts > 24) { m_LoginAttempts = 0; @@ -1239,6 +1240,7 @@ bool CNetworkConnection::stateLogin() return false; // exit now from loop, don't expect a new state } else +#endif { ++m_LoginAttempts; } diff --git a/ryzom/client/src/quic_connection.cpp b/ryzom/client/src/quic_connection.cpp index 576f61bb4a..a52b5e1c1b 100644 --- a/ryzom/client/src/quic_connection.cpp +++ b/ryzom/client/src/quic_connection.cpp @@ -532,12 +532,14 @@ _Function_class_(QUIC_CONNECTION_CALLBACK) bool CQuicConnection::sendDatagram(const uint8 *buffer, uint32 size) { - if (m->Connection && size <= m->MaxSendLength) + if (m->Connection && m->State && CQuicConnection::Connected && size <= m->MaxSendLength.load()) { - QUIC_BUFFER buf; - buf.Buffer = (uint8 *)buffer; - buf.Length = size; - QUIC_STATUS status = MsQuic->DatagramSend(m->Connection, &buf, 1, QUIC_SEND_FLAG_NONE, this); + QUIC_BUFFER *buf = new QUIC_BUFFER(); // wow leak :) + uint8 *copy = new uint8[size]; + memcpy(copy, buffer, size); + buf->Buffer = copy; // (uint8 *)buffer; + buf->Length = size; + QUIC_STATUS status = MsQuic->DatagramSend(m->Connection, buf, 1, QUIC_SEND_FLAG_NONE, this); if (QUIC_FAILED(status)) { nlwarning("DatagramSend failed with %d", status); diff --git a/ryzom/server/src/frontend_service/quic_transceiver.cpp b/ryzom/server/src/frontend_service/quic_transceiver.cpp index ee3a1965cf..f41206fcf9 100644 --- a/ryzom/server/src/frontend_service/quic_transceiver.cpp +++ b/ryzom/server/src/frontend_service/quic_transceiver.cpp @@ -495,7 +495,9 @@ void CQuicTransceiver::datagramReceived(CQuicUserContext *user, const uint8 *buf // Locked block { CAtomicFlagLockYield lock(m->BufferMutex); - m->Buffer->push(buffer, length); + static const uint8 userEvent = TReceivedMessage::User; + static_assert(MsgHeaderSize == sizeof(userEvent)); + m->Buffer->push(&userEvent, MsgHeaderSize, buffer, length); m->Buffer->push((uint8 *)&user, sizeof(user)); // Pointer } } @@ -510,10 +512,12 @@ NLMISC::CBufFIFO *CQuicTransceiver::swapWriteQueue(NLMISC::CBufFIFO *writeQueue) void CQuicTransceiver::sendDatagram(CQuicUserContext *user, const uint8 *buffer, uint32 size) { - QUIC_BUFFER buf; - buf.Buffer = (uint8 *)buffer; - buf.Length = size; - QUIC_STATUS status = MsQuic->DatagramSend((HQUIC)user->Connection, &buf, 1, QUIC_SEND_FLAG_NONE, (void *)user); + QUIC_BUFFER *buf = new QUIC_BUFFER(); // wow leak :) + uint8 *copy = new uint8[size]; + memcpy(copy, buffer, size); + buf->Buffer = copy; // (uint8 *)buffer; + buf->Length = size; + QUIC_STATUS status = MsQuic->DatagramSend((HQUIC)user->Connection, buf, 1, QUIC_SEND_FLAG_NONE, (void *)user); if (QUIC_FAILED(status)) { nlwarning("MsQuic->ConnectionSendDatagram failed with status %d", status);