Problems with pollers and MONO

Regnak

Squire
Apr 1, 2013
319
48
28
Belgium
I haven't detected the origin of the problem yet, but if you have problems with the pollers (shard not appearing online on UOGateway and JoinUO, for example), here's a fix that used to work in the past :

https://github.com/brodock/sunuo/commit/70d29cf0bd65e511d15f36e2ee860a84ad009376

25  src/Network/NetState.cs
@@ -439,6 +439,7 @@ public void Send( Packet p )
try
{
m_Socket.BeginSend( sendBuffer, 0, sendLength, SocketFlags.None, m_OnSend, null );
+ m_Sending = true;
//Console.WriteLine( "Send: {0}: Begin send of {1} bytes", this, sendLength );
}
catch // ( Exception ex )
@@ -486,6 +487,8 @@ public bool Flush()
try
{
m_Socket.BeginSend( buffer, 0, length, SocketFlags.None, m_OnSend, null );
+ m_Sending = true;
+ //m_Socket.Send( buffer, 0, length, SocketFlags.None );
return true;
//Console.WriteLine( "Flush: {0}: Begin send of {1} bytes", this, length );
}
@@ -509,6 +512,8 @@ public static int CoalesceSleep
private void OnSend( IAsyncResult asyncResult )
{
+ m_Sending = false;
+
if ( m_Socket == null )
return;
@@ -522,6 +527,11 @@ private void OnSend( IAsyncResult asyncResult )
return;
}
+ if (m_Disposing && !m_DisposeFinished) {
+ FinishDispose();
+ return;
+ }
+
//Console.WriteLine( "OnSend: {0}: Complete send of {1} bytes", this, bytes );
m_NextCheckActivity = DateTime.Now + TimeSpan.FromMinutes( 1.2 );
@@ -538,6 +548,7 @@ private void OnSend( IAsyncResult asyncResult )
if ( queued != null )
{
m_Socket.BeginSend( queued, 0, length, SocketFlags.None, m_OnSend, null );
+ m_Sending = true;
//Console.WriteLine( "OnSend: {0}: Begin send of {1} bytes", this, length );
}
}
@@ -649,7 +660,7 @@ public void Dispose()
Dispose( true );
}
- private bool m_Disposing;
+ private bool m_Disposing, m_DisposeFinished, m_Sending;
public void Dispose( bool flush )
{
@@ -661,6 +672,16 @@ public void Dispose( bool flush )
if ( flush )
flush = Flush();
+ if (!m_Sending)
+ FinishDispose();
+ }
+
+ public void FinishDispose() {
+ if (m_DisposeFinished)
+ return;
+
+ m_DisposeFinished = true;
+
try { m_Socket.Shutdown( SocketShutdown.Both ); }
catch {}
@@ -777,4 +798,4 @@ public ByteQueue Buffer
}
}
}
-}
+}
0 comments on commit 70d29cf


It is a core modification, and requires a recompilation.

I'm testing it right now and will report if still successful :)
 

Regnak

Squire
Apr 1, 2013
319
48
28
Belgium
It works :)

You actually just have to split the Dispose into two parts (with the FinishDispose), and use the _sending in the NewAsyncSockets ;)

Hopefully this helps someone later ;)
 

Red Squirrel

Citizen
Aug 10, 2015
9
2
3
34
I run UO Gateway, is there anything at my end I can do for this to work without a core mod? Ex: is it like a packet timing issue or something? Seems odd it would only affect when it's under emulation though, it should technically be the same code right?
 
  • Like
Reactions: Regnak

Sharky

Citizen
Oct 19, 2015
13
1
1
44
Seems this issue was never fixed :) Like Regnak said you have to do a core mod to Netstate.cs and Listener.cs in Server/Networks. So far so good seems to be polling now. :)
 
  • Like
Reactions: Regnak