libsimpleio: (reinhard) more debug output. Do not enter backend loop in server object...
authorReinhard Pfau <reinhard.pfau@intra2net.com>
Mon, 22 Sep 2008 12:44:21 +0000 (12:44 +0000)
committerReinhard Pfau <reinhard.pfau@intra2net.com>
Mon, 22 Sep 2008 12:44:21 +0000 (12:44 +0000)
glue_t2n/simpleio_t2n.cpp
glue_t2n/simpleio_t2n.hpp

index a2f55d6..7d00b3d 100644 (file)
@@ -401,7 +401,7 @@ void T2NClientConnection::close()
 /**
  * @brief sends a raw data chunk on the connection.
  *
- * @param data the /raw) data chunk which should be sended.
+ * @param data the (raw) data chunk which should be sended.
  */
 void T2NClientConnection::real_write(const std::string& data)
 {
@@ -611,6 +611,7 @@ void T2NServerConnection::real_write(const std::string& data)
         NOT_REACHED();
         return;
     }
+    module_logger().debug() << "send " << data.size() << " bytes of data";
     ptr->sendData(data);
 } // eo T2NServerConnection::real_write(const std::string)
 
@@ -722,7 +723,9 @@ void T2NServerConnection::newDataSlot()
         NOT_REACHED();
         return;
     }
-    buffer+= ptr->receiveData();
+    std::string new_data= ptr->receiveData();
+    buffer+= new_data;
+    module_logger().debug() << "got " << new_data.size() << " bytes of new data";
     m_got_new_data= true;
     reset_timeout();
 
@@ -761,12 +764,17 @@ void T2NServerConnection::eofSlot()
  */
 T2NServerBase::T2NServerBase( ServerSocketBaseImplementationPtr server_port)
 : m_server_port(server_port)
+, m_new_data_available(false)
 {
     SCOPETRACKER();
     // register our callback for new incoming conncetions.
     server_port->setNewConnectionBaseCallback(
         boost::bind(&T2NServerBase::newConnectionSlot, this, _1)
     );
+    m_signal_client_got_new_data.connect
+    (
+        boost::bind(&T2NServerBase::clientGotNewDataSlot, this)
+    );
 } // eo T2NServerBase::T2NServerBase(ServerSocketBaseImplementationPtr)
 
 
@@ -805,6 +813,15 @@ void T2NServerBase::newConnectionSlot(IOImplementationPtr io_ptr)
 
 
 /**
+ * @brief callback for "new data available" signal
+ */
+void T2NServerBase::clientGotNewDataSlot()
+{
+    m_new_data_available= true;
+} // eo T2NServerBase::clientGotNewDataSlot()
+
+
+/**
  * @brief try to fill the buffers of the managed connections.
  *
  * will be called by T2NServerBase::fill_buffer().
@@ -856,6 +873,14 @@ bool T2NServerBase::fill_connection_buffers()
 bool T2NServerBase::fill_buffer(long long usec_timeout, long long* timeout_remaining)
 {
     SCOPETRACKER();
+
+    if (m_new_data_available)
+    {
+        // short cut if we already know that we have new data:
+        m_new_data_available= false;
+        return true;
+    }
+
     int timeout= 0;
 
     if (usec_timeout<0)
index c57fb8a..a1089f1 100644 (file)
@@ -176,6 +176,8 @@ class T2NServerBase
 
         void newConnectionSlot(SimpleIo::IOImplementationPtr io_ptr);
 
+        void clientGotNewDataSlot();
+
         /*
         ** overloaded methods from t2n classes:
         */
@@ -186,6 +188,7 @@ class T2NServerBase
     protected:
 
         SimpleIo::ServerSocketBaseImplementationPtr m_server_port;
+        bool m_new_data_available;
 
 }; // eo T2NServerBase