mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 14:41:28 +00:00
Style changes (auto, post-inc to pre-inc)
This commit is contained in:
parent
1551e5d908
commit
761c2be722
@ -425,14 +425,11 @@ void EQStream::ProcessPacket(EQProtocolPacket *p)
|
|||||||
uint16 index = seq - SequencedBase;
|
uint16 index = seq - SequencedBase;
|
||||||
Log.Out(Logs::Detail, Logs::Netcode, _L "OP_OutOfOrderAck marking packet acked in queue (queue index = %d, queue size = %d)." __L, index, sqsize);
|
Log.Out(Logs::Detail, Logs::Netcode, _L "OP_OutOfOrderAck marking packet acked in queue (queue index = %d, queue size = %d)." __L, index, sqsize);
|
||||||
if (index < sqsize) {
|
if (index < sqsize) {
|
||||||
std::deque<EQProtocolPacket *>::iterator sitr;
|
SequencedQueue[index]->acked = true;
|
||||||
sitr = SequencedQueue.begin();
|
|
||||||
sitr += index;
|
|
||||||
(*sitr)->acked = true;
|
|
||||||
// flag packets for a resend
|
// flag packets for a resend
|
||||||
uint16 count = 0;
|
uint16 count = 0;
|
||||||
uint32 timeout = AverageDelta * 2 + 100;
|
uint32 timeout = AverageDelta * 2 + 100;
|
||||||
for (sitr = SequencedQueue.begin(); sitr != SequencedQueue.end() && count < index; ++sitr, ++count) {
|
for (auto sitr = SequencedQueue.begin(); sitr != SequencedQueue.end() && count < index; ++sitr, ++count) {
|
||||||
if (!(*sitr)->acked && (*sitr)->sent_time > 0 && (((*sitr)->sent_time + timeout) < Timer::GetCurrentTime())) {
|
if (!(*sitr)->acked && (*sitr)->sent_time > 0 && (((*sitr)->sent_time + timeout) < Timer::GetCurrentTime())) {
|
||||||
(*sitr)->sent_time = 0;
|
(*sitr)->sent_time = 0;
|
||||||
Log.Out(Logs::Detail, Logs::Netcode, _L "OP_OutOfOrderAck Flagging packet %d for retransmission" __L, SequencedBase + count);
|
Log.Out(Logs::Detail, Logs::Netcode, _L "OP_OutOfOrderAck Flagging packet %d for retransmission" __L, SequencedBase + count);
|
||||||
@ -619,19 +616,21 @@ void EQStream::SequencedPush(EQProtocolPacket *p)
|
|||||||
delete p;
|
delete p;
|
||||||
#else
|
#else
|
||||||
MOutboundQueue.lock();
|
MOutboundQueue.lock();
|
||||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
if (uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-Push Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
Log.Out(Logs::Detail, Logs::Netcode, _L "Pre-Push Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L,
|
||||||
}
|
SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.Out(Logs::Detail, Logs::Netcode, _L "Pushing sequenced packet %d of length %d. Base Seq is %d." __L,
|
||||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Pushing sequenced packet %d of length %d. Base Seq is %d." __L, NextOutSeq, p->size, SequencedBase);
|
NextOutSeq, p->size, SequencedBase);
|
||||||
*(uint16 *)(p->pBuffer)=htons(NextOutSeq);
|
*(uint16 *)(p->pBuffer) = htons(NextOutSeq);
|
||||||
SequencedQueue.push_back(p);
|
SequencedQueue.push_back(p);
|
||||||
NextOutSeq++;
|
NextOutSeq++;
|
||||||
|
|
||||||
if(uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
if (uint16(SequencedBase + SequencedQueue.size()) != NextOutSeq) {
|
||||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Push Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L, SequencedBase, SequencedQueue.size(), NextOutSeq);
|
Log.Out(Logs::Detail, Logs::Netcode, _L "Push Invalid Sequenced queue: BS %d + SQ %d != NOS %d" __L,
|
||||||
}
|
SequencedBase, SequencedQueue.size(), NextOutSeq);
|
||||||
|
}
|
||||||
|
|
||||||
MOutboundQueue.unlock();
|
MOutboundQueue.unlock();
|
||||||
#endif
|
#endif
|
||||||
@ -696,8 +695,8 @@ void EQStream::Write(int eq_fd)
|
|||||||
uint16 count = 0;
|
uint16 count = 0;
|
||||||
// get to start of packets
|
// get to start of packets
|
||||||
while (sitr != SequencedQueue.end() && (*sitr)->sent_time > 0) {
|
while (sitr != SequencedQueue.end() && (*sitr)->sent_time > 0) {
|
||||||
sitr++;
|
++sitr;
|
||||||
count++;
|
++count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop until both are empty or MaxSends is reached
|
// Loop until both are empty or MaxSends is reached
|
||||||
@ -735,11 +734,9 @@ void EQStream::Write(int eq_fd)
|
|||||||
NonSeqEmpty=true;
|
NonSeqEmpty=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sitr != SequencedQueue.end()) {
|
||||||
if (sitr!=SequencedQueue.end()) {
|
|
||||||
|
|
||||||
uint16 seq_send = SequencedBase + count; //just for logging...
|
uint16 seq_send = SequencedBase + count; //just for logging...
|
||||||
|
|
||||||
if(SequencedQueue.empty()) {
|
if(SequencedQueue.empty()) {
|
||||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Tried to write a packet with an empty queue (%d is past next out %d)" __L, seq_send, NextOutSeq);
|
Log.Out(Logs::Detail, Logs::Netcode, _L "Tried to write a packet with an empty queue (%d is past next out %d)" __L, seq_send, NextOutSeq);
|
||||||
SeqEmpty=true;
|
SeqEmpty=true;
|
||||||
@ -1362,7 +1359,7 @@ void EQStream::Decay()
|
|||||||
if ((GetExecutablePlatform() == ExePlatformWorld || GetExecutablePlatform() == ExePlatformZone) && RETRANSMIT_TIMEOUT_MULT && retransmittimeout) {
|
if ((GetExecutablePlatform() == ExePlatformWorld || GetExecutablePlatform() == ExePlatformZone) && RETRANSMIT_TIMEOUT_MULT && retransmittimeout) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
MOutboundQueue.lock();
|
MOutboundQueue.lock();
|
||||||
for (std::deque<EQProtocolPacket *>::iterator sitr = SequencedQueue.begin(); sitr != SequencedQueue.end(); sitr++, count++) {
|
for (auto sitr = SequencedQueue.begin(); sitr != SequencedQueue.end(); ++sitr, count++) {
|
||||||
if (!(*sitr)->acked && (*sitr)->sent_time > 0 && ((*sitr)->sent_time + retransmittimeout) < Timer::GetCurrentTime()) {
|
if (!(*sitr)->acked && (*sitr)->sent_time > 0 && ((*sitr)->sent_time + retransmittimeout) < Timer::GetCurrentTime()) {
|
||||||
(*sitr)->sent_time = 0;
|
(*sitr)->sent_time = 0;
|
||||||
Log.Out(Logs::Detail, Logs::Netcode, _L "Timeout exceeded for seq %d. Flagging packet for retransmission" __L, SequencedBase + count);
|
Log.Out(Logs::Detail, Logs::Netcode, _L "Timeout exceeded for seq %d. Flagging packet for retransmission" __L, SequencedBase + count);
|
||||||
|
|||||||
@ -250,8 +250,7 @@ void EQStreamFactory::CheckTimeout()
|
|||||||
|
|
||||||
void EQStreamFactory::WriterLoop()
|
void EQStreamFactory::WriterLoop()
|
||||||
{
|
{
|
||||||
std::map<std::pair<uint32, uint16>, std::shared_ptr<EQStream>>::iterator stream_itr;
|
bool havework = true;
|
||||||
bool havework=true;
|
|
||||||
std::vector<std::shared_ptr<EQStream>> wants_write;
|
std::vector<std::shared_ptr<EQStream>> wants_write;
|
||||||
std::vector<std::shared_ptr<EQStream>>::iterator cur, end;
|
std::vector<std::shared_ptr<EQStream>>::iterator cur, end;
|
||||||
bool decay = false;
|
bool decay = false;
|
||||||
@ -260,7 +259,7 @@ void EQStreamFactory::WriterLoop()
|
|||||||
WriterRunning = true;
|
WriterRunning = true;
|
||||||
DecayTimer.Enable();
|
DecayTimer.Enable();
|
||||||
|
|
||||||
while(sock!=-1) {
|
while (sock != -1) {
|
||||||
MWriterRunning.lock();
|
MWriterRunning.lock();
|
||||||
if (!WriterRunning)
|
if (!WriterRunning)
|
||||||
break;
|
break;
|
||||||
@ -269,34 +268,36 @@ void EQStreamFactory::WriterLoop()
|
|||||||
havework = false;
|
havework = false;
|
||||||
wants_write.clear();
|
wants_write.clear();
|
||||||
|
|
||||||
decay=DecayTimer.Check();
|
decay = DecayTimer.Check();
|
||||||
|
|
||||||
//copy streams into a seperate list so we dont have to keep
|
// copy streams into a seperate list so we dont have to keep
|
||||||
//MStreams locked while we are writting
|
// MStreams locked while we are writting
|
||||||
MStreams.lock();
|
MStreams.lock();
|
||||||
for(stream_itr=Streams.begin();stream_itr!=Streams.end();++stream_itr) {
|
for (auto stream_itr = Streams.begin(); stream_itr != Streams.end(); ++stream_itr) {
|
||||||
// If it's time to decay the bytes sent, then let's do it before we try to write
|
// If it's time to decay the bytes sent, then let's do it before we try to write
|
||||||
if (decay)
|
if (decay)
|
||||||
stream_itr->second->Decay();
|
stream_itr->second->Decay();
|
||||||
|
|
||||||
//bullshit checking, to see if this is really happening, GDB seems to think so...
|
// bullshit checking, to see if this is really happening, GDB seems to think so...
|
||||||
if(stream_itr->second == nullptr) {
|
if (stream_itr->second == nullptr) {
|
||||||
fprintf(stderr, "ERROR: nullptr Stream encountered in EQStreamFactory::WriterLoop for: %i:%i", stream_itr->first.first, stream_itr->first.second);
|
fprintf(stderr,
|
||||||
|
"ERROR: nullptr Stream encountered in EQStreamFactory::WriterLoop for: %i:%i",
|
||||||
|
stream_itr->first.first, stream_itr->first.second);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream_itr->second->HasOutgoingData()) {
|
if (stream_itr->second->HasOutgoingData()) {
|
||||||
havework=true;
|
havework = true;
|
||||||
stream_itr->second->PutInUse();
|
stream_itr->second->PutInUse();
|
||||||
wants_write.push_back(stream_itr->second);
|
wants_write.push_back(stream_itr->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MStreams.unlock();
|
MStreams.unlock();
|
||||||
|
|
||||||
//do the actual writes
|
// do the actual writes
|
||||||
cur = wants_write.begin();
|
cur = wants_write.begin();
|
||||||
end = wants_write.end();
|
end = wants_write.end();
|
||||||
for(; cur != end; ++cur) {
|
for (; cur != end; ++cur) {
|
||||||
(*cur)->Write(sock);
|
(*cur)->Write(sock);
|
||||||
(*cur)->ReleaseFromUse();
|
(*cur)->ReleaseFromUse();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user