• R/O
  • SSH
  • HTTPS

tidesnet: Commit


Commit MetaInfo

Revisão68 (tree)
Hora2020-01-28 20:04:41
Autorquiret

Mensagem de Log

- adjusted the error management of BasicServer to the realities of stable socket OS implementations

Mudança Sumário

Diff

--- server_backbone/include/server_backbone.h (revision 67)
+++ server_backbone/include/server_backbone.h (revision 68)
@@ -101,14 +101,13 @@
101101 // This is usually caused by an uncaught exception; should be used for debugging purposes.
102102 // (the lib maintainer wants to prevent this!!!)
103103 return;
104- }
105- virtual void OnNetListenerReset( const char *errMsg, std::uint16_t port, TidesNetwork::eConnFamily connFamily, TidesNetwork::eConnProtocol protoType )
106- {
107- // Called when a thread resets its network ConnReceiver handle.
108- // Necessary because certain socket errors require resetting to reuse the handle.
109- // Not an error for the user, but should be logged.
110- return;
111104 }
105+ virtual void OnNetListenerNetworkException( const char *errmsg, std::uint16_t port, TidesNetwork::eConnFamily connFamily, TidesNetwork::eConnProtocol protoType )
106+ {
107+ // Called when a strange network event occurred during socket protocol connection acquisition handshake that should be investigated.
108+ // It indicates that a connection has been dropped prior to being passed to the runtime.
109+ return;
110+ }
112111
113112 private:
114113 NativeExecutive::CExecutiveManager *natExec;
--- server_backbone/src/main.cpp (revision 67)
+++ server_backbone/src/main.cpp (revision 68)
@@ -133,8 +133,7 @@
133133 socket_listener *listen_info = this->threadPluginSocketListener.GetPluginStruct( thread );
134134
135135 TidesNetwork::ConnReceiver *th_listener = listen_info->listener;
136-
137- canRestartListening:
136+
138137 try
139138 {
140139 while ( th_listener->IsClosed() == false )
@@ -143,7 +142,22 @@
143142 execMan->CheckHazardCondition();
144143
145144 // Do the regular runtime.
146- TidesNetwork::NetSocket *accSocket = th_listener->Accept();
145+ TidesNetwork::NetSocket *accSocket = nullptr;
146+
147+ try
148+ {
149+ accSocket = th_listener->Accept();
150+ }
151+ catch( TidesNetwork::TidesException& except )
152+ {
153+ // If our listening socket is not yet closed then we have encountered a real error that needs to be investigated.
154+ if ( th_listener->IsClosed() == false )
155+ {
156+ this->OnNetListenerNetworkException( except.get_msg(), port, connFamily, protoType );
157+ }
158+
159+ // Either way, we just spin again to try the next waiting connection in-line.
160+ }
147161
148162 if ( accSocket == nullptr )
149163 {
@@ -215,20 +229,6 @@
215229 throw;
216230 }
217231 }
218- }
219- catch( TidesNetwork::TidesException& except )
220- {
221- // Recreate the network handle.
222- bool couldRevive = th_listener->Reset( port, connFamily, protoType, false );
223-
224- if ( couldRevive )
225- {
226- this->OnNetListenerReset( except.get_msg(), port, connFamily, protoType );
227-
228- // Just reset the thread.
229- goto canRestartListening;
230- }
231- // else we just close the thread.
232232 }
233233 catch( ... )
234234 {
Show on old repository browser