• R/O
  • SSH
  • HTTPS

tidesnet: Commit


Commit MetaInfo

Revisão70 (tree)
Hora2020-01-29 08:26:59
Autorquiret

Mensagem de Log

- added support for AF_UNIX style connection listeners inside BasicServer of tidesnet_server_backbone

Mudança Sumário

Diff

--- server_backbone/include/server_backbone.h (revision 69)
+++ server_backbone/include/server_backbone.h (revision 70)
@@ -93,9 +93,13 @@
9393
9494 // Adds an ethernet-based socket connection listener.
9595 void AddNetListener( std::uint16_t port, TidesNetwork::eConnFamily connFamily, TidesNetwork::eConnProtocol protoType );
96+ void AddNetListener( const char *pathName, TidesNetwork::eConnProtocol protoType );
9697
98+private:
99+ void ConsumeNetListener( TidesNetwork::ConnReceiver *listener );
100+
97101 protected:
98- virtual void OnNetListenerDeath( std::uint16_t port, TidesNetwork::eConnFamily connFamily, TidesNetwork::eConnProtocol protoType )
102+ virtual void OnNetListenerDeath( const TidesNetwork::ConnReceiver *listener )
99103 {
100104 // Called by the dying net listener thread.
101105 // This is usually caused by an uncaught exception; should be used for debugging purposes.
@@ -102,7 +106,7 @@
102106 // (the lib maintainer wants to prevent this!!!)
103107 return;
104108 }
105- virtual void OnNetListenerNetworkException( const char *errmsg, std::uint16_t port, TidesNetwork::eConnFamily connFamily, TidesNetwork::eConnProtocol protoType )
109+ virtual void OnNetListenerNetworkException( const char *errmsg, const TidesNetwork::ConnReceiver *listener )
106110 {
107111 // Called when a strange network event occurred during socket protocol connection acquisition handshake that should be investigated.
108112 // It indicates that a connection has been dropped prior to being passed to the runtime.
--- server_backbone/src/main.cpp (revision 69)
+++ server_backbone/src/main.cpp (revision 70)
@@ -103,25 +103,10 @@
103103 return this->hasRecoveredFromSuddenDeath;
104104 }
105105
106-void BasicServer::AddNetListener( std::uint16_t port, TidesNetwork::eConnFamily connFamily, TidesNetwork::eConnProtocol protoType )
106+void BasicServer::ConsumeNetListener( TidesNetwork::ConnReceiver *new_listener )
107107 {
108- NativeExecutive::CReadWriteReadContext <> ctxRunning( this->lockRunning );
109-
110- // If we are not running then this makes no sense.
111- if ( this->isRunning == false )
112- {
113- throw TidesNetwork::TidesException( "server is not running" );
114- }
115-
116108 TidesNetwork::TidesNet *netMan = this->netMan;
117109
118- TidesNetwork::ConnReceiver *new_listener = netMan->CreateNetListener( port, connFamily, protoType );
119-
120- if ( new_listener == nullptr )
121- {
122- throw TidesNetwork::TidesException( "could not listen to ethernet socket" );
123- }
124-
125110 try
126111 {
127112 NativeExecutive::CExecutiveManager *execMan = this->natExec;
@@ -153,7 +138,7 @@
153138 // If our listening socket is not yet closed then we have encountered a real error that needs to be investigated.
154139 if ( th_listener->IsClosed() == false )
155140 {
156- this->OnNetListenerNetworkException( except.get_msg(), port, connFamily, protoType );
141+ this->OnNetListenerNetworkException( except.get_msg(), new_listener );
157142 }
158143
159144 // Either way, we just spin again to try the next waiting connection in-line.
@@ -235,7 +220,7 @@
235220 // Really bad, the runtime should inform itself about this.
236221 listen_info->hasDied = true;
237222
238- this->OnNetListenerDeath( port, connFamily, protoType );
223+ this->OnNetListenerDeath( new_listener );
239224 throw;
240225 }
241226 }, 0, "socklisten");
@@ -267,4 +252,48 @@
267252
268253 throw;
269254 }
255+}
256+
257+void BasicServer::AddNetListener( std::uint16_t port, TidesNetwork::eConnFamily connFamily, TidesNetwork::eConnProtocol protoType )
258+{
259+ NativeExecutive::CReadWriteReadContext <> ctxRunning( this->lockRunning );
260+
261+ // If we are not running then this makes no sense.
262+ if ( this->isRunning == false )
263+ {
264+ throw TidesNetwork::TidesException( "server is not running" );
265+ }
266+
267+ TidesNetwork::TidesNet *netMan = this->netMan;
268+
269+ TidesNetwork::ConnReceiver *new_listener = netMan->CreateNetListener( port, connFamily, protoType );
270+
271+ if ( new_listener == nullptr )
272+ {
273+ throw TidesNetwork::TidesException( "could not listen to ethernet socket" );
274+ }
275+
276+ this->ConsumeNetListener( new_listener );
270277 }
278+
279+void BasicServer::AddNetListener( const char *portName, TidesNetwork::eConnProtocol protoType )
280+{
281+ NativeExecutive::CReadWriteReadContext <> ctxRunning( this->lockRunning );
282+
283+ // If we are not running then this makes no sense.
284+ if ( this->isRunning == false )
285+ {
286+ throw TidesNetwork::TidesException( "server is not running" );
287+ }
288+
289+ TidesNetwork::TidesNet *netMan = this->netMan;
290+
291+ TidesNetwork::ConnReceiver *new_listener = netMan->CreateNetListener( portName, TidesNetwork::eConnFamily::UNIX, protoType );
292+
293+ if ( new_listener == nullptr )
294+ {
295+ throw TidesNetwork::TidesException( "could not listen to ethernet socket" );
296+ }
297+
298+ this->ConsumeNetListener( new_listener );
299+}
Show on old repository browser