• R/O
  • SSH
  • HTTPS

tidesnet: Commit


Commit MetaInfo

Revision85 (tree)
Time2020-05-02 00:11:47
Authorquiret

Log Message

- reliability upgrades

Change Summary

Incremental Difference

--- server_backbone/include/server_backbone.h (revision 84)
+++ server_backbone/include/server_backbone.h (revision 85)
@@ -110,6 +110,8 @@
110110 }
111111 virtual void OnNetListenerNetworkException( const char *errmsg, const TidesNetwork::ConnReceiver *listener )
112112 {
113+ // WARNING: errmsg can be nullptr!
114+
113115 // Called when a strange network event occurred during socket protocol connection acquisition handshake that should be investigated.
114116 // It indicates that a connection has been dropped prior to being passed to the runtime.
115117 return;
--- server_backbone/src/main.cpp (revision 84)
+++ server_backbone/src/main.cpp (revision 85)
@@ -35,8 +35,9 @@
3535 // Remove the thread from our list.
3636 LIST_REMOVE( item->node );
3737
38- // Make sure the thread has finished running.
39- nativeMan->JoinThread( item->procThread );
38+ // Ask the thread to terminate.
39+ // This acts as a more powerful join operation; we do not want to screw around with clients taking too long.
40+ nativeMan->TerminateThread( item->procThread, true );
4041
4142 if ( item->hasDied )
4243 {
@@ -75,9 +76,8 @@
7576 // The thread should starve to death now.
7677 item->clientSocket->Close();
7778
78- // Wait till it closed down.
79- // The thread removes itself from the runtime list.
80- nativeMan->JoinThread( item->procThread );
79+ // Do a coordinated termination of the thread; just don't screw around.
80+ nativeMan->TerminateThread( item->procThread, true );
8181
8282 if ( item->hasDied )
8383 {
@@ -138,7 +138,7 @@
138138 // If our listening socket is not yet closed then we have encountered a real error that needs to be investigated.
139139 if ( th_listener->IsClosed() == false )
140140 {
141- this->OnNetListenerNetworkException( except.get_msg(), new_listener );
141+ this->OnNetListenerNetworkException( except.get_opt_msg(), new_listener );
142142 }
143143
144144 // Either way, we just spin again to try the next waiting connection in-line.
@@ -163,6 +163,11 @@
163163 // Run the application code.
164164 this->connection_cb( thread, accSocket, this->connection_userData );
165165 }
166+ catch( NativeExecutive::threadTerminationException& )
167+ {
168+ // That's OK. We were just asked to terminate thus do it.
169+ throw;
170+ }
166171 catch( ... )
167172 {
168173 runtime_thread *runtime_info = this->threadPluginRuntimeThread.GetPluginStruct( thread );
@@ -215,6 +220,11 @@
215220 }
216221 }
217222 }
223+ catch( NativeExecutive::threadTerminationException& )
224+ {
225+ // We asked for a coordinated termination thus it's OK.
226+ throw;
227+ }
218228 catch( ... )
219229 {
220230 // Really bad, the runtime should inform itself about this.
@@ -227,7 +237,7 @@
227237
228238 if ( listenerThread == nullptr )
229239 {
230- throw TidesNetwork::TidesException( "could not create listener thread" );
240+ throw eir_exception(); // "could not create listener thread"
231241 }
232242
233243 socket_listener *listen_info = this->threadPluginSocketListener.GetPluginStruct( listenerThread );
@@ -261,7 +271,7 @@
261271 // If we are not running then this makes no sense.
262272 if ( this->isRunning == false )
263273 {
264- throw TidesNetwork::TidesException( "server is not running" );
274+ throw eir_exception(); // ( "server is not running" );
265275 }
266276
267277 TidesNetwork::TidesNet *netMan = this->netMan;
@@ -268,11 +278,6 @@
268278
269279 TidesNetwork::ConnReceiver *new_listener = netMan->CreateNetListener( port, connFamily, protoType );
270280
271- if ( new_listener == nullptr )
272- {
273- throw TidesNetwork::TidesException( "could not listen to ethernet socket" );
274- }
275-
276281 this->ConsumeNetListener( new_listener );
277282 }
278283
@@ -283,7 +288,7 @@
283288 // If we are not running then this makes no sense.
284289 if ( this->isRunning == false )
285290 {
286- throw TidesNetwork::TidesException( "server is not running" );
291+ throw eir_exception(); //( "server is not running" );
287292 }
288293
289294 TidesNetwork::TidesNet *netMan = this->netMan;
@@ -290,11 +295,6 @@
290295
291296 TidesNetwork::ConnReceiver *new_listener = netMan->CreateNetListener( portName, TidesNetwork::eConnFamily::UNIX, protoType );
292297
293- if ( new_listener == nullptr )
294- {
295- throw TidesNetwork::TidesException( "could not listen to ethernet socket" );
296- }
297-
298298 this->ConsumeNetListener( new_listener );
299299 }
300300
@@ -305,7 +305,7 @@
305305 // If we are not running then this makes no sense.
306306 if ( this->isRunning == false )
307307 {
308- throw TidesNetwork::TidesException( "server is not running" );
308+ throw eir_exception(); //( "server is not running" );
309309 }
310310
311311 TidesNetwork::TidesNet *netMan = this->netMan;
@@ -312,11 +312,6 @@
312312
313313 TidesNetwork::ConnReceiver *new_listener = netMan->CreateNetListener( bindAddr, port, protoType );
314314
315- if ( new_listener == nullptr )
316- {
317- throw TidesNetwork::TidesException( "could not listen to ethernet socket" );
318- }
319-
320315 this->ConsumeNetListener( new_listener );
321316 }
322317
@@ -327,7 +322,7 @@
327322 // If we are not running then this makes no sense.
328323 if ( this->isRunning == false )
329324 {
330- throw TidesNetwork::TidesException( "server is not running" );
325+ throw eir_exception(); //( "server is not running" );
331326 }
332327
333328 TidesNetwork::TidesNet *netMan = this->netMan;
@@ -334,10 +329,5 @@
334329
335330 TidesNetwork::ConnReceiver *new_listener = netMan->CreateNetListener( bindAddr, port, protoType );
336331
337- if ( new_listener == nullptr )
338- {
339- throw TidesNetwork::TidesException( "could not listen to ethernet socket" );
340- }
341-
342332 this->ConsumeNetListener( new_listener );
343333 }
\ No newline at end of file
Show on old repository browser