libt2n-git Archives

Subject: C++ inter-process communication library branch, switch-to-epoll, updated. v0.7-12-g098b934

From: libt2n-git@xxxxxxxxxxxxxxxxxxxxxxx
To: libt2n-git@xxxxxxxxxxxxxxxxxxxxxxx
Date: Tue, 9 Apr 2024 16:58:34 +0200 (CEST)
The branch, switch-to-epoll has been updated
  discards  5b03131581b05d9f5d325e05a22e5507b6d7fc5d (commit)
       via  098b93440230d3533f316d73c7836be159ecd567 (commit)
       via  e6a693de53b6cf7e384fe517458f972c65dbdb92 (commit)

This update added new revisions after undoing existing revisions.  That is
to say, the old revision is not a strict subset of the new revision.  This
situation occurs when you --force push a change and generate a repository
containing something like this:

 * -- * -- B -- O -- O -- O (5b03131581b05d9f5d325e05a22e5507b6d7fc5d)
            \
             N -- N -- N (098b93440230d3533f316d73c7836be159ecd567)

When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.


- Log -----------------------------------------------------------------
commit 098b93440230d3533f316d73c7836be159ecd567
Author: Gabriel Braga <gabriel.braga@xxxxxxxxxxxxx>
Date:   Tue Apr 9 16:53:06 2024 +0200

    Change monotonic clock to get time in milliseconds for epoll_wait() (#7785)
    
    Changes to the timeout structure were necessary,such as using milliseconds
    instead of microseconds. This fix some bugs with timeout events.

commit e6a693de53b6cf7e384fe517458f972c65dbdb92
Author: Gabriel Braga <gabriel.braga@xxxxxxxxxxxxx>
Date:   Tue Apr 9 16:48:19 2024 +0200

    Switch socket management API to epoll() (#7785)
    
    Previously all the server and client sockets were being managed by
    the select() API, which operates using a fixed amount of client
    sockets. This commit changes the code to adapt to the epoll() API.
    This commit also could have a performance improvement due to epoll's
    architecture.
    
    Note: next commits should fix:
        - The timeout from sec to millisecs as the epoll_wait()
        uses millisecs.
        - Unit tests.

-----------------------------------------------------------------------

Summary of changes:
 CMakeLists.txt         |    7 ++---
 src/socket_handler.cpp |    2 -
 src/socket_server.cpp  |    7 ++++-
 test/callback.cpp      |   41 +++++++++++++++---------------------
 test/cmdgroup.cpp      |    4 +-
 test/comm.cpp          |   36 ++++++++++++++++----------------
 test/getsocket.cpp     |    2 +-
 test/hello.cpp         |   26 +++++++++++-----------
 test/newserver.cpp     |   16 ++++---------
 test/reconnect.cpp     |   28 ++++++++++++------------
 test/reentrant.cpp     |   21 +++---------------
 test/serialize.cpp     |    2 +-
 test/simplecmd.cpp     |    8 +++---
 test/timeout.cpp       |   32 ++++++++++++++--------------
 test/wrapper.cpp       |   54 ++++++++++++++++++++++++------------------------
 15 files changed, 130 insertions(+), 156 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 74b3e4d..25f4754 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -31,9 +31,8 @@ include_directories(${XMLPP_INCLUDE_DIRS})
 link_directories(${XMLPP_LIBRARY_DIRS})
 
 # Documentation
-option(DOCUMENTATION "Generate API documentation with Doxygen" ON)
 find_package(Doxygen)
-if(DOXYGEN_FOUND AND DOCUMENTATION)
+if(DOXYGEN_FOUND)
    # Find doxy config
    message(STATUS "Doxygen found.")
    set(DOXY_DIR "${CMAKE_SOURCE_DIR}/doc")
@@ -62,9 +61,9 @@ if(DOXYGEN_FOUND AND DOCUMENTATION)
    add_custom_target(docs ALL DEPENDS ${CMAKE_BINARY_DIR}/doc/html/index.html)
 
    message(STATUS "Generating API documentation with Doxygen.")
-else(DOXYGEN_FOUND AND DOCUMENTATION)
+else(DOXYGEN_FOUND)
    message(STATUS "Not generating API documentation.")
-endif(DOXYGEN_FOUND AND DOCUMENTATION)
+endif(DOXYGEN_FOUND)
 
 # Spec file
 configure_file(${CMAKE_SOURCE_DIR}/libt2n.spec.in 
${CMAKE_SOURCE_DIR}/libt2n.spec @ONLY)
diff --git a/src/socket_handler.cpp b/src/socket_handler.cpp
index 5347188..355f623 100644
--- a/src/socket_handler.cpp
+++ b/src/socket_handler.cpp
@@ -64,7 +64,6 @@ socket_handler::socket_handler(int _sock, socket_type_value 
_socket_type)
  */
 socket_handler::~socket_handler()
 {
-//    cout << "DELETING SOCKET: ~socket_handler"<<endl;
     if (sock != -1)
     {
         shutdown(sock,SHUT_RDWR);
@@ -85,7 +84,6 @@ void socket_handler::close()
         // graceful shutdown
         shutdown(sock, SHUT_RDWR);\
         //taking it out of the epoll pool
-//        cout << "DELETING SOCKET: socket_handler::close()" << getpid()<< 
endl;
 
         remove_from_epoll(sock);
         ::close(sock);
diff --git a/src/socket_server.cpp b/src/socket_server.cpp
index 70ec702..b8c4099 100644
--- a/src/socket_server.cpp
+++ b/src/socket_server.cpp
@@ -201,6 +201,11 @@ void socket_server::new_connection()
     add_to_epoll(newsock,nc);
 }
 
+/** @brief look for new connections and new data in any of the existing 
connections
+    @param timeout wait until new data is found, max timeout millisecs.
+            -1: wait endless
+            0: return instantly
+*/
 bool socket_server::fill_buffer(int timeout)
 {
     int nfds = epoll_wait(epoll_fd, epoll_events, EPOLL_MAX_EVENTS, timeout);
@@ -264,8 +269,6 @@ bool socket_server::fill_connection_buffers()
 void socket_server::remove_connection_socket(int sock)
 {
     int r = sockets_set.erase(sock);
-//    cout << "DELETING SOCKET: socket_server::remove_connection_socket"<<endl;
-
     if (r)
         remove_from_epoll(sock);
 }
diff --git a/test/callback.cpp b/test/callback.cpp
index 57d1ebc..eb600cb 100644
--- a/test/callback.cpp
+++ b/test/callback.cpp
@@ -87,25 +87,23 @@ BOOST_AUTO_TEST_CASE(ServerNewConnCallback)
             try
             {
                 string data;
+                // wait till server is up
                 sleep(1);
 
                 {
                     socket_client_connection sc("./socket");
-//                    cout<< "client writing"<<endl;
 
                     sc.write("ABC");
 
                     // wait half a sec
-                    sc.fill_buffer(1000);
+                    sc.fill_buffer(500000);
                     sc.get_packet(data);
 
                     // close the connection
-//                    cout<<" CLOSING CLIENT"<< getpid()<<endl;
-
                 }
-            } catch(std::exception &e)
+            } catch(...)
             {
-                std::cerr << "exception in child. ignoring\n" << e.what();
+                std::cerr << "exception in child. ignoring\n";
             }
 
             // don't call atexit and stuff
@@ -122,23 +120,19 @@ BOOST_AUTO_TEST_CASE(ServerNewConnCallback)
             // max 3 sec
             for (int i=0; i < 3; i++)
             {
-//                cout<< "server filling buffer"<<endl;
-                ss.fill_buffer(1000);
+                ss.fill_buffer(1000000);
 
                 string data;
                 unsigned int cid;
                 if(ss.get_packet(data,cid))
                 {
                     server_connection* con=ss.get_connection(cid);
-//                    cout<< "server writing on connection: "<< cid<<endl;
-
                     con->write("XYZ");
                 }
             }
             
BOOST_CHECK_EQUAL(true,static_cast<bool>(callback_done[new_connection]));
             
BOOST_CHECK_EQUAL(false,static_cast<bool>(callback_done[connection_closed]));
             
BOOST_CHECK_EQUAL(false,static_cast<bool>(callback_done[connection_deleted]));
-//            cout<< "EVERYTHING WORKED"<<endl;
         }
     }
 }
@@ -167,7 +161,7 @@ BOOST_AUTO_TEST_CASE(ServerConnClosedCallback)
                     sc.write("ABC");
 
                     // wait half a sec
-                    sc.fill_buffer(1000);
+                    sc.fill_buffer(500000);
                     sc.get_packet(data);
 
                     // close the connection
@@ -191,7 +185,7 @@ BOOST_AUTO_TEST_CASE(ServerConnClosedCallback)
             // max 3 sec
             for (int i=0; i < 3; i++)
             {
-                ss.fill_buffer(1000);
+                ss.fill_buffer(1000000);
 
                 string data;
                 unsigned int cid;
@@ -232,7 +226,7 @@ BOOST_AUTO_TEST_CASE(ServerConnDeletedCallback)
                     sc.write("ABC");
 
                     // wait half a sec
-                    sc.fill_buffer(1000);
+                    sc.fill_buffer(500000);
                     sc.get_packet(data);
 
                     // close the connection
@@ -256,7 +250,7 @@ BOOST_AUTO_TEST_CASE(ServerConnDeletedCallback)
             // max 3 sec
             for (int i=0; i < 3; i++)
             {
-                ss.fill_buffer(1000);
+                ss.fill_buffer(1000000);
 
                 string data;
                 unsigned int cid;
@@ -276,7 +270,6 @@ BOOST_AUTO_TEST_CASE(ServerConnDeletedCallback)
     }
 }
 
-
 BOOST_AUTO_TEST_CASE(ServerCallbackOrder)
 {
     switch(child_pid=fork())
@@ -301,7 +294,7 @@ BOOST_AUTO_TEST_CASE(ServerCallbackOrder)
                     sc.write("1");
 
                     // wait half a sec
-                    sc.fill_buffer(1000);
+                    sc.fill_buffer(500000);
                     sc.get_packet(data);
 
                     sc.write("2");
@@ -329,7 +322,7 @@ BOOST_AUTO_TEST_CASE(ServerCallbackOrder)
 
             for (int i=0; i < 5; i++)
             {
-                ss.fill_buffer(1000);
+                ss.fill_buffer(500000);
 
                 string data;
                 unsigned int cid;
@@ -349,7 +342,7 @@ BOOST_AUTO_TEST_CASE(ServerCallbackOrder)
 
             for (int i=0; i < 4; i++)
             {
-                ss.fill_buffer(1000);
+                ss.fill_buffer(500000);
 
                 string data;
                 unsigned int cid;
@@ -383,7 +376,7 @@ BOOST_AUTO_TEST_CASE(ClientConnClosedCallback)
                 // max 3 sec
                 for (int i=0; i < 3; i++)
                 {
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
 
                     string data;
                     unsigned int cid;
@@ -413,7 +406,7 @@ BOOST_AUTO_TEST_CASE(ClientConnClosedCallback)
             sc.write("ABC");
 
             // wait half a sec
-            sc.fill_buffer(1000);
+            sc.fill_buffer(500000);
             sc.get_packet(data);
 
             
BOOST_CHECK_EQUAL(false,static_cast<bool>(callback_done[new_connection]));
@@ -442,7 +435,7 @@ BOOST_AUTO_TEST_CASE(ClientConnDeletedCallback)
                 // max 3 sec
                 for (int i=0; i < 3; i++)
                 {
-                    ss.fill_buffer(2000);
+                    ss.fill_buffer(1000000);
 
                     string data;
                     unsigned int cid;
@@ -472,8 +465,8 @@ BOOST_AUTO_TEST_CASE(ClientConnDeletedCallback)
 
                 sc.write("ABC");
 
-                // wait a sec
-                sc.fill_buffer(1000);
+                // wait half a sec
+                sc.fill_buffer(500000);
                 sc.get_packet(data);
             }
 
diff --git a/test/cmdgroup.cpp b/test/cmdgroup.cpp
index a58687e..942fd88 100644
--- a/test/cmdgroup.cpp
+++ b/test/cmdgroup.cpp
@@ -195,7 +195,7 @@ BOOST_AUTO_TEST_CASE(GroupOk)
 
                 // max 10 sec
                 for (int i=0; i < 10; i++)
-                    cs.handle(1000);
+                    cs.handle(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";
@@ -242,7 +242,7 @@ BOOST_AUTO_TEST_CASE(WrongGroup)
 
                 // max 10 sec
                 for (int i=0; i < 10; i++)
-                    cs.handle(1000);
+                    cs.handle(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";
diff --git a/test/comm.cpp b/test/comm.cpp
index 7f84241..7b301a6 100644
--- a/test/comm.cpp
+++ b/test/comm.cpp
@@ -83,7 +83,7 @@ BOOST_AUTO_TEST_CASE(UnixCommToServer)
             // max 10 sec
             while (time(NULL) < t0 + 10 )
             {
-                ss.fill_buffer(1000);
+                ss.fill_buffer(1000000);
 
                 if(ss.get_packet(data))
                     break;
@@ -115,7 +115,7 @@ BOOST_AUTO_TEST_CASE(UnixCommToServerAndBack)
                 // max 10 sec
                 while (time(NULL) < t0 + 10 )
                 {
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
 
                     string data;
                     unsigned int cid;
@@ -153,14 +153,14 @@ BOOST_AUTO_TEST_CASE(UnixCommToServerAndBack)
 
             sc.write("ABC");
 
-            sc.fill_buffer(1000);
+            sc.fill_buffer(1000000);
             sc.get_packet(data);
 
             BOOST_CHECK_EQUAL(string("DEF"),data);
 
             sc.write("HAHA");
 
-            sc.fill_buffer(1000);
+            sc.fill_buffer(1000000);
             sc.get_packet(data);
 
             BOOST_CHECK_EQUAL(string("xyz"),data);
@@ -192,7 +192,7 @@ BOOST_AUTO_TEST_CASE(UnixCommToServerAndBackBig)
                 // max 10 sec
                 while (time(NULL) < t0 + 10 )
                 {
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
 
                     string data;
                     unsigned int cid;
@@ -229,7 +229,7 @@ BOOST_AUTO_TEST_CASE(UnixCommToServerAndBackBig)
             sc.write(string().insert(0,100*1024,'x'));
 
             while (!sc.get_packet(data))
-                sc.fill_buffer(1000);
+                sc.fill_buffer(1000000);
 
             BOOST_CHECK_EQUAL(string().insert(0,100*1024,'y'),data);
 
@@ -256,7 +256,7 @@ BOOST_AUTO_TEST_CASE(IPCommToServer)
             {
                 // wait till server is up
                 sleep(1);
-                socket_client_connection sc(6665);
+                socket_client_connection sc(6666);
                 sc.write("hello");
             } catch(...)
             {
@@ -270,14 +270,14 @@ BOOST_AUTO_TEST_CASE(IPCommToServer)
         default:
         // parent
         {
-            socket_server ss(6665);
+            socket_server ss(6666);
 
             time_t t0 = time(NULL);
 
             // max 10 sec
             while (time(NULL) < t0 + 10 )
             {
-                ss.fill_buffer(1000);
+                ss.fill_buffer(1000000);
 
                 if(ss.get_packet(data))
                     break;
@@ -301,7 +301,7 @@ BOOST_AUTO_TEST_CASE(IPCommToServerAndBack)
         {
             try
             {
-                socket_server ss(6665);
+                socket_server ss(6666);
                 ss.set_logging(&cerr,debug);
 
                 time_t t0 = time(NULL);
@@ -309,7 +309,7 @@ BOOST_AUTO_TEST_CASE(IPCommToServerAndBack)
                 // max 10 sec
                 while (time(NULL) < t0 + 10 )
                 {
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
 
                     string data;
                     unsigned int cid;
@@ -342,17 +342,17 @@ BOOST_AUTO_TEST_CASE(IPCommToServerAndBack)
 
             // wait till server is up
             sleep(1);
-            socket_client_connection sc(6665);
+            socket_client_connection sc(6666);
             sc.write("ABC");
 
-            sc.fill_buffer(1000);
+            sc.fill_buffer(1000000);
             sc.get_packet(data);
 
             BOOST_CHECK_EQUAL(string("DEF"),data);
 
             sc.write("HAHA");
 
-            sc.fill_buffer(1000);
+            sc.fill_buffer(1000000);
             sc.get_packet(data);
 
             BOOST_CHECK_EQUAL(string("xyz"),data);
@@ -377,7 +377,7 @@ BOOST_AUTO_TEST_CASE(IPCommToServerAndBackBig)
         {
             try
             {
-                socket_server ss(6665);
+                socket_server ss(6666);
                 ss.set_logging(&cerr,debug);
 
                 time_t t0 = time(NULL);
@@ -385,7 +385,7 @@ BOOST_AUTO_TEST_CASE(IPCommToServerAndBackBig)
                 // max 10 sec
                 while (time(NULL) < t0 + 10 )
                 {
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
 
                     string data;
                     unsigned int cid;
@@ -418,12 +418,12 @@ BOOST_AUTO_TEST_CASE(IPCommToServerAndBackBig)
 
             // wait till server is up
             sleep(1);
-            socket_client_connection sc(6665);
+            socket_client_connection sc(6666);
 
             sc.write(string().insert(0,100*1024,'x'));
 
             while (!sc.get_packet(data))
-                sc.fill_buffer(1000);
+                sc.fill_buffer(1000000);
 
             BOOST_CHECK_EQUAL(string().insert(0,2048*1024,'y'),data);
 
diff --git a/test/getsocket.cpp b/test/getsocket.cpp
index 5db3de8..edd5eb3 100644
--- a/test/getsocket.cpp
+++ b/test/getsocket.cpp
@@ -154,7 +154,7 @@ BOOST_AUTO_TEST_CASE(SocketCheck)
                 for (int i=0; i < 10; i++)
                 {
                     SocketSet = ss.get_sockets_set();
-                    cs.handle(1000);
+                    cs.handle(1000000);
                 }
             } catch(...)
             {
diff --git a/test/hello.cpp b/test/hello.cpp
index dd653c4..a7a885d 100644
--- a/test/hello.cpp
+++ b/test/hello.cpp
@@ -76,7 +76,7 @@ BOOST_AUTO_TEST_CASE(HelloOk)
 
                 // max 10 sec
                 for (int i=0; i < 10; i++)
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";
@@ -125,7 +125,7 @@ BOOST_AUTO_TEST_CASE(BadTag)
 
                 // max 10 sec
                 for (int i=0; i < 10; i++)
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";
@@ -146,7 +146,7 @@ BOOST_AUTO_TEST_CASE(BadTag)
 
             command_client cc(&sc);
 
-            t2n_exception* ep= cc.get_constructor_exception();
+            t2n_exception* ep=cc.get_constuctor_exception();
 
             string errormsg;
             if (ep)
@@ -184,7 +184,7 @@ BOOST_AUTO_TEST_CASE(BadVersion)
 
                 // max 10 sec
                 for (int i=0; i < 10; i++)
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";
@@ -205,7 +205,7 @@ BOOST_AUTO_TEST_CASE(BadVersion)
 
             command_client cc(&sc);
 
-            t2n_exception* ep= cc.get_constructor_exception();
+            t2n_exception* ep=cc.get_constuctor_exception();
 
             string errormsg;
             if (ep)
@@ -242,7 +242,7 @@ BOOST_AUTO_TEST_CASE(SeparatorMissing)
 
                 // max 10 sec
                 for (int i=0; i < 10; i++)
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";
@@ -263,7 +263,7 @@ BOOST_AUTO_TEST_CASE(SeparatorMissing)
 
             command_client cc(&sc);
 
-            t2n_exception* ep= cc.get_constructor_exception();
+            t2n_exception* ep=cc.get_constuctor_exception();
 
             string errormsg;
             if (ep)
@@ -309,7 +309,7 @@ BOOST_AUTO_TEST_CASE(WrongByteOrder)
 
                 // max 10 sec
                 for (int i=0; i < 10; i++)
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";
@@ -330,7 +330,7 @@ BOOST_AUTO_TEST_CASE(WrongByteOrder)
 
             command_client cc(&sc);
 
-            t2n_exception* ep= cc.get_constructor_exception();
+            t2n_exception* ep=cc.get_constuctor_exception();
 
             string errormsg;
             if (ep)
@@ -365,7 +365,7 @@ BOOST_AUTO_TEST_CASE(OtherServerBig)
 
                 // max 3 sec
                 for (int i=0; i < 3; i++)
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";
@@ -386,7 +386,7 @@ BOOST_AUTO_TEST_CASE(OtherServerBig)
 
             command_client cc(&sc);
 
-            t2n_exception* ep= cc.get_constructor_exception();
+            t2n_exception* ep=cc.get_constuctor_exception();
 
             string errormsg;
             if (ep)
@@ -421,7 +421,7 @@ BOOST_AUTO_TEST_CASE(OtherServerSmall)
 
                 // max 3 sec
                 for (int i=0; i < 3; i++)
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";
@@ -442,7 +442,7 @@ BOOST_AUTO_TEST_CASE(OtherServerSmall)
 
             command_client cc(&sc);
 
-            t2n_exception* ep= cc.get_constructor_exception();
+            t2n_exception* ep=cc.get_constuctor_exception();
 
             string errormsg;
             if (ep)
diff --git a/test/newserver.cpp b/test/newserver.cpp
index 3ee9fc9..5fa21b4 100644
--- a/test/newserver.cpp
+++ b/test/newserver.cpp
@@ -123,7 +123,6 @@ BOOST_FIXTURE_TEST_SUITE(test_newserver, 
KillChildOnShutdownFixture)
 
 BOOST_AUTO_TEST_CASE(NewServerSocket)
 {
-
     switch(child_pid=fork())
     {
         case -1:
@@ -134,34 +133,29 @@ BOOST_AUTO_TEST_CASE(NewServerSocket)
         case 0:
         // child
         {
-//            std::cout << "CHILD:";
             try
             {
                 {
-//                    cout<< " CREATING SOCKET SERVER" <<endl;
                     socket_server ss("./socket");
                     // ss.set_logging(&cerr,debug);
-                    printf("CREATION SUCCESS");
                     command_server cs(ss);
+
                     // handle new connection and just one command
-                    cs.handle(10000);
-                    cs.handle(10000);
+                    cs.handle(10000000);
+                    cs.handle(10000000);
                 }
 
-                sleep(2);
+                sleep(1);
 
                 // close socket, create new one
                 {
-//                    cout<< " CREATING SOCKET SERVER" <<endl;
                     socket_server ss("./socket");
-
                     // ss.set_logging(&cerr,debug);
                     command_server cs(ss);
-                    printf("CREATION SUCCESS");
 
                     // max 30 sec
                     for (int i=0; i < 30; i++)
-                        cs.handle(1000);
+                        cs.handle(1000000);
                 }
             } catch(...)
             {
diff --git a/test/reconnect.cpp b/test/reconnect.cpp
index 133a9e9..bd4f60b 100644
--- a/test/reconnect.cpp
+++ b/test/reconnect.cpp
@@ -67,7 +67,7 @@ BOOST_AUTO_TEST_CASE(simple_reconnect)
                 // max 10 sec
                 while (time(NULL) < t0 + 10 )
                 {
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
 
                     string data;
                     unsigned int cid;
@@ -109,14 +109,14 @@ BOOST_AUTO_TEST_CASE(simple_reconnect)
             string data;
 
             while (!sc.get_packet(data))
-                sc.fill_buffer(1000);
+                sc.fill_buffer(1000000);
 
             sc.reconnect();
 
             sc.write("x");
 
             while (!sc.get_packet(data))
-                sc.fill_buffer(1000);
+                sc.fill_buffer(1000000);
 
             BOOST_CHECK_EQUAL(string().insert(0,100,'X'),data);
         }
@@ -144,7 +144,7 @@ BOOST_AUTO_TEST_CASE(reconnect_with_close)
                 // max 10 sec
                 while (time(NULL) < t0 + 10 )
                 {
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
 
                     string data;
                     unsigned int cid;
@@ -186,7 +186,7 @@ BOOST_AUTO_TEST_CASE(reconnect_with_close)
             string data;
 
             while (!sc.get_packet(data))
-                sc.fill_buffer(1000);
+                sc.fill_buffer(1000000);
 
             sc.close();
 
@@ -198,7 +198,7 @@ BOOST_AUTO_TEST_CASE(reconnect_with_close)
             sc.write("x");
 
             while (!sc.get_packet(data))
-                sc.fill_buffer(1000);
+                sc.fill_buffer(1000000);
 
             BOOST_CHECK_EQUAL(string().insert(0,100,'X'),data);
         }
@@ -226,7 +226,7 @@ BOOST_AUTO_TEST_CASE(reconnect_buffer_complete)
                 // max 10 sec
                 while (time(NULL) < t0 + 10 )
                 {
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
 
                     string data;
                     unsigned int cid;
@@ -266,7 +266,7 @@ BOOST_AUTO_TEST_CASE(reconnect_buffer_complete)
             string data;
 
             while (!sc.packet_available())
-                sc.fill_buffer(1000);
+                sc.fill_buffer(1000000);
 
             sc.reconnect();
 
@@ -300,7 +300,7 @@ BOOST_AUTO_TEST_CASE(reconnect_buffer_several_complete)
                 // max 10 sec
                 while (time(NULL) < t0 + 10 )
                 {
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
 
                     string data;
                     unsigned int cid;
@@ -345,7 +345,7 @@ BOOST_AUTO_TEST_CASE(reconnect_buffer_several_complete)
 
             // max 3 sec
             while (time(NULL) < t0 + 3 )
-                sc.fill_buffer(1000);
+                sc.fill_buffer(1000000);
 
             // we now should have packets complete packets in the buffer
 
@@ -392,7 +392,7 @@ BOOST_AUTO_TEST_CASE(reconnect_buffer_no_incomplete1)
                 // max 10 sec
                 while (time(NULL) < t0 + 10 )
                 {
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
 
                     string data;
                     unsigned int cid;
@@ -437,7 +437,7 @@ BOOST_AUTO_TEST_CASE(reconnect_buffer_no_incomplete1)
 
             // max 3 sec
             while (time(NULL) < t0 + 3 )
-                sc.fill_buffer(1000);
+                sc.fill_buffer(1000000);
 
             // we now should have one complete packet and some stuff in the 
buffer
 
@@ -474,7 +474,7 @@ BOOST_AUTO_TEST_CASE(reconnect_buffer_no_incomplete2)
                 // max 10 sec
                 while (time(NULL) < t0 + 10 )
                 {
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
 
                     string data;
                     unsigned int cid;
@@ -530,7 +530,7 @@ BOOST_AUTO_TEST_CASE(reconnect_buffer_no_incomplete2)
 
             // max 3 sec
             while (time(NULL) < t0 + 3 )
-                sc.fill_buffer(1000);
+                sc.fill_buffer(1000000);
 
             // we now should have one complete packet and some stuff in the 
buffer
 
diff --git a/test/reentrant.cpp b/test/reentrant.cpp
index d1a6583..204e741 100644
--- a/test/reentrant.cpp
+++ b/test/reentrant.cpp
@@ -66,7 +66,7 @@ string testfunc(const string& str)
 
     // call handle, eventually reentrant
     if (global_server)
-        global_server->handle(1);
+        global_server->handle(10000);
 
     ++seen_client_requests;
 
@@ -136,7 +136,6 @@ class testfunc_cmd : public libt2n::command
 
 
 #include <boost/serialization/export.hpp>
-#include "monotonic_clock.hxx"
 
 BOOST_CLASS_EXPORT(reentrant::testfunc_cmd)
 BOOST_CLASS_EXPORT(reentrant::testfunc_res)
@@ -158,7 +157,7 @@ BOOST_AUTO_TEST_CASE(ReentrantServer)
         // child
         {
             // wait till server is up
-            sleep(1);
+            sleep(2);
 
             // hammer the server
             for (int i = 0; i < fork_count; i++)
@@ -215,26 +214,14 @@ BOOST_AUTO_TEST_CASE(ReentrantServer)
             while (seen_client_requests < all_requests)
             {
                 ++safety_check;
-
                 if (safety_check > 10) {
                     std::cerr << "reached safety check, aborting.\n";
                     break;
                 }
 
-                int maxtime=1000;
-                int millisec_checkpoit;
-
+                long long maxtime=1000000;
                 while(maxtime > 0)
-                {
-                    millisec_checkpoit = monotonic_clock_gettime_msec();
-                    if (millisec_checkpoit != -1)
-                    {
-                        cs.handle(maxtime);
-                        maxtime -= abs(monotonic_clock_gettime_msec() - 
millisec_checkpoit);
-                    }
-                    else _exit(1);
-                }
-                cout<<"LEFT"<<endl;
+                    cs.handle(maxtime,&maxtime);
             }
 
             global_server = NULL;
diff --git a/test/serialize.cpp b/test/serialize.cpp
index 443c1c8..8db3740 100644
--- a/test/serialize.cpp
+++ b/test/serialize.cpp
@@ -144,7 +144,7 @@ BOOST_AUTO_TEST_CASE(ClientSerializeErr)
 
                 // max 10 sec
                 for (int i=0; i < 10; i++)
-                    cs.handle(1000);
+                    cs.handle(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";
diff --git a/test/simplecmd.cpp b/test/simplecmd.cpp
index e12014a..97fa6da 100644
--- a/test/simplecmd.cpp
+++ b/test/simplecmd.cpp
@@ -146,7 +146,7 @@ BOOST_AUTO_TEST_CASE(SimpleCmd)
 
                 // max 10 sec
                 for (int i=0; i < 10; i++)
-                    cs.handle(1000);
+                    cs.handle(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";
@@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(SimpleException)
 
                 // max 10 sec
                 for (int i=0; i < 10; i++)
-                    cs.handle(1000);
+                    cs.handle(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";
@@ -249,7 +249,7 @@ BOOST_AUTO_TEST_CASE(BigReturn)
 
                 // max 10 sec
                 for (int i=0; i < 10; i++)
-                    cs.handle(1000);
+                    cs.handle(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";
@@ -296,7 +296,7 @@ BOOST_AUTO_TEST_CASE(BigParameter)
 
                 // max 60 sec - we need atleast 28 handle calls to transfer 
the buffer
                 for (int i=0; i < 60; i++) {
-                    cs.handle(1000);
+                    cs.handle(1000000);
             }
             } catch(...)
             {
diff --git a/test/timeout.cpp b/test/timeout.cpp
index a0b9ef2..936cc6a 100644
--- a/test/timeout.cpp
+++ b/test/timeout.cpp
@@ -145,13 +145,13 @@ protected:
         // this is an evil hack to get access to real_write, don't ever do 
this in an app!!!
         real_write_connection *rwc=(real_write_connection*)ssc;
 
-        // we write one char each 0.5 sec
+        // we write one char each 0.2 sec
         for (int pos=0; pos < data.size(); pos++)
         {
             string onebyte;
             onebyte+=data[pos];
             rwc->real_write(onebyte);
-            usleep(500000);
+            usleep(200000);
         }
     }
 };
@@ -219,7 +219,7 @@ BOOST_AUTO_TEST_CASE(HelloTimeoutNothing)
 
                 // max 10 sec
                 for (int i=0; i < 10; i++)
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";
@@ -237,9 +237,9 @@ BOOST_AUTO_TEST_CASE(HelloTimeoutNothing)
             // wait till server is up
             sleep(1);
             socket_client_connection sc("./socket");
-            command_client cc(&sc,1,1);
+            command_client cc(&sc,1000000,1000000);
 
-            t2n_exception* ep= cc.get_constructor_exception();
+            t2n_exception* ep=cc.get_constuctor_exception();
 
             string errormsg;
             if (ep)
@@ -281,7 +281,7 @@ BOOST_AUTO_TEST_CASE(HelloTimeoutSlowData)
 
                 // max 10 sec
                 for (int i=0; i < 10; i++)
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";
@@ -299,9 +299,9 @@ BOOST_AUTO_TEST_CASE(HelloTimeoutSlowData)
             // wait till server is up
             sleep(1);
             socket_client_connection sc("./socket");
-            command_client cc(&sc,100,100);
+            command_client cc(&sc,1000000,1000000);
 
-            t2n_exception* ep= cc.get_constructor_exception();
+            t2n_exception* ep=cc.get_constuctor_exception();
 
             string errormsg;
             if (ep)
@@ -338,7 +338,7 @@ BOOST_AUTO_TEST_CASE(CommandTimeout)
 
                 // max 10 sec
                 for (int i=0; i < 10; i++)
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";
@@ -357,7 +357,7 @@ BOOST_AUTO_TEST_CASE(CommandTimeout)
             sleep(1);
             socket_client_connection sc("./socket");
 
-            command_client cc(&sc,1,1);
+            command_client cc(&sc,1000000,1000000);
             result_container rc;
 
             string errormsg;
@@ -401,7 +401,7 @@ BOOST_AUTO_TEST_CASE(CommandSlowResponse)
                 // max 10 sec
                 for (int i=0; i < 10; i++)
                 {
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
 
                     string data;
                     unsigned int cid;
@@ -434,7 +434,7 @@ BOOST_AUTO_TEST_CASE(CommandSlowResponse)
             sleep(1);
             socket_client_connection sc("./socket");
 
-            command_client cc(&sc,10,10);
+            command_client cc(&sc,1000000,1000000);
             result_container rc;
 
             string errormsg;
@@ -613,7 +613,7 @@ BOOST_AUTO_TEST_CASE(DisconnectOnRead)
             // max 5 sec
             while (time(NULL) < t0 + 5 )
             {
-                ss.fill_buffer(1000);
+                ss.fill_buffer(1000000);
 
                 string data;
                 ss.get_packet(data);
@@ -656,7 +656,7 @@ BOOST_AUTO_TEST_CASE(DisconnectOnRead)
                     // max 10 sec
                     while (time(NULL) < t0 + 10 )
                     {
-                        ss.fill_buffer(1000);
+                        ss.fill_buffer(1000000);
 
                         if (ss.get_packet(received))
                             break;
@@ -716,7 +716,7 @@ BOOST_AUTO_TEST_CASE(BreakAccept)
             // max 5 sec
             while (time(NULL) < t0 + 5 )
             {
-                ss.fill_buffer(1000);
+                ss.fill_buffer(1000000);
 
                 string data;
                 ss.get_packet(data);
@@ -759,7 +759,7 @@ BOOST_AUTO_TEST_CASE(BreakAccept)
                     // max 10 sec
                     while (time(NULL) < t0 + 10 )
                     {
-                        ss.fill_buffer(1000);
+                        ss.fill_buffer(1000000);
 
                         if (ss.get_packet(received))
                             break;
diff --git a/test/wrapper.cpp b/test/wrapper.cpp
index 1765c08..5fedaf5 100644
--- a/test/wrapper.cpp
+++ b/test/wrapper.cpp
@@ -202,30 +202,30 @@ class cmd_group_x_client : public command_client
 {
     public:
         cmd_group_x_client(libt2n::client_connection *_c,
-         int _command_timeout_sec=command_timeout_millisec_default,
-         int _hello_timeout_sec=hello_timeout_millisec_default)
-         : libt2n::command_client(_c,_command_timeout_sec,_hello_timeout_sec)
+         long long _command_timeout_usec=command_timeout_usec_default,
+         long long _hello_timeout_usec=hello_timeout_usec_default)
+         : libt2n::command_client(_c,_command_timeout_usec,_hello_timeout_usec)
         {}
 
-        int serverfunc(int i)
-        {
-            libt2n::result_container rc;
+    int serverfunc(int i)
+    {
+        libt2n::result_container rc;
 
-            send_command(new serverfunc_cmd(i), rc);
-            serverfunc_res* res=dynamic_cast<serverfunc_res*>(rc.get_result());
-            if (!res) throw libt2n::t2n_communication_error("result object of 
wrong type");
-            return res->get_data();
-        }
+        send_command(new serverfunc_cmd(i), rc);
+        serverfunc_res* res=dynamic_cast<serverfunc_res*>(rc.get_result());
+        if (!res) throw libt2n::t2n_communication_error("result object of 
wrong type");
+        return res->get_data();
+    }
 
-        std::string getserverlog(void)
-        {
-            libt2n::result_container rc;
+    std::string getserverlog(void)
+    {
+        libt2n::result_container rc;
 
-            send_command(new getserverlog_cmd(), rc);
-            getserverlog_res* 
res=dynamic_cast<getserverlog_res*>(rc.get_result());
-            if (!res) throw libt2n::t2n_communication_error("result object of 
wrong type");
-            return res->get_data();
-        }
+        send_command(new getserverlog_cmd(), rc);
+        getserverlog_res* res=dynamic_cast<getserverlog_res*>(rc.get_result());
+        if (!res) throw libt2n::t2n_communication_error("result object of 
wrong type");
+        return res->get_data();
+    }
 };
 
 typedef T2nSingletonWrapper<cmd_group_x_client> wraptype;
@@ -268,7 +268,7 @@ public:
 
                         // max 10 sec
                         for (; !close_server && !kill_server && i < 10; i++)
-                            cs.handle(1000);
+                            cs.handle(1000000);
                     }
                 } catch(...)
                 {
@@ -358,14 +358,14 @@ BOOST_AUTO_TEST_CASE(reconnect_after_close)
     wraptype::set_connection(auto_ptr<ConnectionWrapper>
         (new ReconnectSocketWrapper("./socket")));
 
-    wraptype::get_connection_wrapper()->set_command_timeout_millisec(200);
-    wraptype::get_connection_wrapper()->set_hello_timeout_millisec(200);
+    wraptype::get_connection_wrapper()->set_command_timeout_usec(3000000);
+    wraptype::get_connection_wrapper()->set_hello_timeout_usec(3000000);
 
     // 42 closes connection on the server side
     t2n_exec(&cmd_group_x_client::serverfunc)(42);
 
     string out=t2n_exec(&cmd_group_x_client::getserverlog)();
-    // cout<< "SERVER LOG: "<< out <<endl;
+
     // count the number of times that "new connection accepted" appears in the 
server log
     string::size_type p=0;
     int cnt=0;
@@ -406,8 +406,8 @@ BOOST_AUTO_TEST_CASE(ignore_handler_reconnects)
     wraptype::set_connection(auto_ptr<ConnectionWrapper>
         (new ReconnectIgnoreFailureSocketWrapper("./socket")));
 
-    wraptype::get_connection_wrapper()->set_command_timeout_millisec(3);
-    wraptype::get_connection_wrapper()->set_hello_timeout_millisec(3);
+    wraptype::get_connection_wrapper()->set_command_timeout_usec(3000000);
+    wraptype::get_connection_wrapper()->set_hello_timeout_usec(3000000);
 
     // 42 closes connection on the server side
     t2n_exec(&cmd_group_x_client::serverfunc)(42);
@@ -478,7 +478,7 @@ BOOST_AUTO_TEST_CASE(ignore_finds_lateserver)
 
                     // max 10 sec
                     for (; !close_server && !kill_server && i < 10; i++)
-                        cs.handle(1000);
+                        cs.handle(1000000);
                 }
             } catch(...)
             {
@@ -533,7 +533,7 @@ BOOST_AUTO_TEST_CASE(ignore_wrongserver)
 
                 // max 10 sec
                 for (int i=0; i < 10; i++)
-                    ss.fill_buffer(1000);
+                    ss.fill_buffer(1000000);
             } catch(...)
             {
                 std::cerr << "exception in child. ignoring\n";


hooks/post-receive
-- 
C++ inter-process communication library

--
libt2n-git - see http://www.intra2net.com/en/developer/libt2n for details.
To unsubscribe send a mail to libt2n-git+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread
  • C++ inter-process communication library branch, switch-to-epoll, updated. v0.7-12-g098b934, libt2n-git <=