View Full Version : repost of code that works REALLY well for me
Armanthuz
03-13-2004, 05:06 AM
Been searching for 10 min now cant find original author of this codes post, but its not me. I just fixed it a bit. Solved 98 percent of all the LDs peoeple were having on my server... Just wanted to repost in fixed version so it dont get lost...
this goes in client.cpp in world folder starting at line 419 right after the line that says "int32 tmpaccid = 0;"
long LOCounter;
LOCounter = 0;
do {
charid = database.GetCharacterInfo(char_name, &tmpaccid, &zoneID);
LOCounter++;
}while ((zoneID == 0) && (LOCounter < 10000));
Thanks to whoever figured out original code and problem, worked very well..
samandhi
03-13-2004, 05:29 AM
screamingogre was the original one that came out with that one... Though there was some discussion about it.. and the LOCounter was not initialized as it should have been, and the statement LOCounter < 1000 was set as LOCounter > 1000.... and dont forget this one too:
I based mine on time passed, that way it doesn't matter how fast your machine is. This code waits 20 seconds before it gives up. Note that if it does get a good zone id, it breaks out of the loop.
Code:
__time64_t curtime1,curtime2;
_time64(&curtime1);
do
{
charid = database.GetCharacterInfo(char_name, &tmpaccid, &zoneID);
_time64(&curtime2);
}while(curtime2 - curtime1 <= 20 && zoneID == 0);
kathgar
03-13-2004, 06:18 AM
That code is a horrible hack and I would not suggest using it on any heavily populated server.
samandhi
03-13-2004, 06:29 AM
:)
Windcatcher
03-13-2004, 06:35 AM
I don't know if it pertains to this issue, but my server is running Client::EnterWorld() in a different thread for each person playing so the world server doesn't freeze. Potentially this same thing could be done on non-ZP servers. If anyone wants to log in to test it feel free. If the server stays up with no problems I'll release what I have later tonight.
WC
Edit: I did some looking at the code in question and what I'm doing could conceivably be done in the enterworld case block as well, where the above code lives. My understanding is that the world server wants to get the zone ID but the zone server hasn't written it yet. Is this correct?
Armanthuz
03-13-2004, 07:21 AM
So if i understand this right...
If you slow down world.exe by using that counter you can (under heavy usage) stall or freeze up people attempting to shift zones? Instead windcatcher is proposing to make it so each person attempting to enter a diff zone each gets a thread and therefore can wait whatever amount of time necc without holding up others from zoning?
samandhi
03-13-2004, 07:25 AM
My understanding is that the world server wants to get the zone ID but the zone server hasn't written it yet. Is this correct? Yes, I think (If I am understanding it correclty aslo) that is what is happening....
I don't know if it pertains to this issue, but my server is running Client::EnterWorld() in a different thread for each person playing so the world server doesn't freeze. I believe that is VERY relevant to this issue... And also believe making it a person by person case would better solve the issue... :)
Windcatcher
03-13-2004, 08:06 AM
I'm going to try running that case block in a different thread and then I'll put my server back up. I do multhreaded programming at work to death (albeit in Java) so I think I can do it. We'll wee how it works...
WC
samandhi
03-13-2004, 09:01 AM
Great!!!!!! I look forward to the results...:)
Windcatcher
03-13-2004, 10:07 AM
Okay, my server is up and unlocked. My implementation of ClientList and ZSList should be thread-safe, and I have Client::EnterWorld() and the OP_EnterWorld portion of the case block running in separate threads from the main thread. It's working like a champ for me, but I need people to log in so I can see if the world server handles multiple clients simultaneously going through the EnterWorld process. The world server will either stay up or it will crash, but this is the only way to be sure that everything is thread-safe.
WC
samandhi
03-13-2004, 10:32 AM
give me a time (and the name of your server) and Ill log in.. You can log in at the same time (ish) and well see what we see....:)
Windcatcher
03-13-2004, 10:35 AM
I have the server up right now, though I'm already logged in. It''s called Windcatcher's ZoneProxy Test Server. Someone already logged in and while that was happening I zoned so both clients were going through the enterworld process at the same time. So far no problems -- at this point I think I need lots of people to just log in and stress it.
This change affects other things as well -- for instance, doing /who all should always work regardless of whether someone is logging in.
WC
P.S. I just re-uploaded my server code with all of the changes. Threre is more info on it in this thread:
http://www.eqemulator.net/forums/viewtopic.php?p=73082#73082
All of my changes are in #ifdef...ZONEPROXY...#endif blocks so as not to affect anything else, but it means that to get multithreaded support you'll have to compile with ZoneProxy support on.
Windcatcher
03-13-2004, 06:07 PM
Well the changes I made were close, but testing showed that it wasn't quite right. I've since found some more things that needed fixing and I've got the server back up. I'll leave it up overnight for any night owls that want to log in :P
WC
Armanthuz
03-14-2004, 04:36 AM
spent around 45 mins on it so far zoning back and forth , cant get it to puke yet.. :)
Windcatcher
03-14-2004, 04:39 AM
Yeah I couldn't get it to fail last night before I went to bed either, but I think the real test is when there are multiple people logging in and zoning back and forth at the same time. That would really test the multithreaded code and was what caused the crash before I made the latest round of changes.
WC
Windcatcher
03-14-2004, 02:32 PM
I had to make a slew of changes today and it might be working better. The newest version is available here:
http://prdownloads.sourceforge.net/eqemu/EQEmu_0.5.5-DR1-ZP.zip?download
In the last hour I increased the ZoneProxy discovery timeout from 5 to 10 seconds, because testing showed that with 5 seconds ZoneProxy wasn't being found every time. Anyway, this has all the multithreaded changes required to perform the EnterWorld process in a separate thread and might solve the latency problems. Give a try, and make sure to stress test it...
WC
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.