[FIXED] Two servers enter, one server leaves

Found a bug in UOX3? Or experienced a server crash? Perhaps you've noticed a broken feature? Post the details here!
Post Reply
Mindless Automaton
UOX3 Apprentice
Posts: 189
Joined: Wed May 10, 2006 3:48 am
Has thanked: 0
Been thanked: 1 time
Contact:

Two servers enter, one server leaves

Post by Mindless Automaton »

From the land of "Nobody would ever do that.."

If you fire up 2 servers with the same port, the 2nd server does not go gracefully.

Code: Select all

 	UOX3.exe!abort() Line 77	C++
 	UOX3.exe!terminate() Line 58	C++
 	[External Code]	
>	[Inline Frame] UOX3.exe!std::thread::join() Line 182	C++
 	UOX3.exe!Shutdown(int retCode) Line 1744	C++
 	UOX3.exe!cNetworkStuff::sockInit() Line 289	C++
 	UOX3.exe!cNetworkStuff::cNetworkStuff() Line 504	C++
 	UOX3.exe!InitClasses() Line 1547	C++
 	UOX3.exe!main(int argc, char * * argv) Line 2604	C++
 	[External Code]	
Unhandled exception at 0x00007FF7E64B3900 in UOX3.exe: Fatal program exit requested.

Fatality!
Mindless Automaton
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

In uox3.cpp, around line 1745... I changed
    cons.join();
to
    if( retCode != FATAL_UOX3_ALLOC_NETWORK )
        cons.join();
This seems to make it exit the second instance of UOX3 more gracefully, though the end result is still the same either way - only one server can run on the same port :P
-= Ho Eyo He Hum =-
Mindless Automaton
UOX3 Apprentice
Posts: 189
Joined: Wed May 10, 2006 3:48 am
Has thanked: 0
Been thanked: 1 time
Contact:

Post by Mindless Automaton »

Do I just see this happen because I have VS2017 installed? If I didnt have it installed, would it just be like "oh well" and close the command prompt window and I would never know intead of offer to debug?

The reason I ask is because it appears that maybe anything that causes one of these FATAL_UOX3_* lines to fire in UOX.cpp seems to cause unhappiness.

We have your edit:

Code: Select all

    if( retCode != FATAL_UOX3_ALLOC_NETWORK )
        cons.join();
We screw up our map path so they are not found:

Console:

Code: Select all

ERROR:  Fatal Error: No maps found
| ERROR:  Check the settings for DATADIRECTORY in uox.ini
o----------------------------------------------------------------------------------------------------------------------o|
| Beginning UOX final shut down sequence...
| HTMLTemplates object detected. Writing Offline HTML Now...
| Cleaning up item and character memory...                                                                       [done]
| Destroying class objects and pointers... Destroying JS instances...                                            [done]
|                                                                                                                [done]
Then you get your UOX3 has stopped working window, Debug, Close Program.

Debug In VS2017 has:

Code: Select all

Unhandled exception at 0x00007FF684E43900 in UOX3.exe: Fatal program exit requested.
 	UOX3.exe!abort() Line 77	C++
 	UOX3.exe!terminate() Line 58	C++
 	[External Code]	
>	[Inline Frame] UOX3.exe!std::thread::join() Line 182	C++
 	UOX3.exe!Shutdown(int retCode) Line 1745	C++
 	UOX3.exe!CMulHandler::Load() Line 446	C++
 	UOX3.exe!main(int argc, char * * argv) Line 2642	C++
 	[External Code]	
Now if we change your edit to this:

Code: Select all

	if( retCode != FATAL_UOX3_MAP_NOT_FOUND )
		cons.join();
Console:

Code: Select all

ERROR:  Fatal Error: No maps found
| ERROR:  Check the settings for DATADIRECTORY in uox.ini
o----------------------------------------------------------------------------------------------------------------------o|
| Beginning UOX final shut down sequence...
| HTMLTemplates object detected. Writing Offline HTML Now...
| Cleaning up item and character memory...                                                                       [done]
| Destroying class objects and pointers... Destroying JS instances...                                            [done]
|                                                                                                                [done]
o----------------------------------------------------------------------------------------------------------------------o| Server shutdown complete!
| Thank you for supporting UOX3
o----------------------------------------------------------------------------------------------------------------------o| Exiting UOX with errorlevel 350
| Press Return to exit
Do keyboards still have a Return key? :P Hit Enter, console window closes.

I guess if the cleanup finishes up ok, it really doesn't matter what happens at the end there, so feel free to ignore this one. :)

Thanks!
Mindless Automaton
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

In the next episode of "Xuri makes changes without knowing what they really do", let's try to change that portion of the code to this:
    //Lets wait for console thread to quit here
    if( !retCode )
        cons.join();
Seems to be working ok for both normal shutdown, datapath error and double socket binding error, but there might be other errors where it doesn't ^^
-= Ho Eyo He Hum =-
Mindless Automaton
UOX3 Apprentice
Posts: 189
Joined: Wed May 10, 2006 3:48 am
Has thanked: 0
Been thanked: 1 time
Contact:

Post by Mindless Automaton »

Xuri wrote: Sun Nov 08, 2020 7:22 am In the next episode of "Xuri makes changes without knowing what they really do", let's try to change that portion of the code to this:
    //Lets wait for console thread to quit here
    if( !retCode )
        cons.join();
Seems to be working ok for both normal shutdown, datapath error and double socket binding error, but there might be other errors where it doesn't ^^
Well part of the name is eXperiment, so we are just playing the game.. sort of. :)
Mindless Automaton
Linux - UOX3 - 0.99.5 dev branch
Win10Pro 19042.572 - UOX3 0.99.3a; Razor 1.0.14; Client 7.0.87.11 or 4.0.11c (Patch 0)
Post Reply