Rolled handle infrastructure into rpcc.
[invirt/third/libt4.git] / rpc / rpctest.cc
index f2e8c7d..f8395e9 100644 (file)
@@ -7,16 +7,20 @@
 #include <getopt.h>
 #include <unistd.h>
 #include <string.h>
+#include "threaded_log.h"
 
 #define NUM_CL 2
 
-char log_thread_prefix = 'r';
-
 static rpcs *server;  // server rpc object
 static rpcc *clients[NUM_CL];  // client rpc object
 static string dst; //server's ip address
 static in_port_t port;
 
+using std::cout;
+using std::endl;
+using namespace std::chrono;
+using std::vector;
+
 // server-side handlers. they must be methods of some class
 // to simplify rpcs::reg(). a server process can have handlers
 // from multiple classes.
@@ -79,7 +83,7 @@ static void startserver() {
 static void testmarshall() {
     marshall m;
     rpc_protocol::request_header rh{1,2,3,4,5};
-    m.pack_header(rh);
+    m.write_header(rh);
     VERIFY(((string)m).size()==rpc_protocol::RPC_HEADER_SZ);
     int i = 12345;
     unsigned long long l = 1223344455L;
@@ -97,7 +101,7 @@ static void testmarshall() {
 
     unmarshall un(b, true);
     rpc_protocol::request_header rh1;
-    un.unpack_header(rh1);
+    un.read_header(rh1);
     VERIFY(memcmp(&rh,&rh1,sizeof(rh))==0);
     int i1;
     unsigned long long l1;
@@ -132,7 +136,7 @@ static void client1(size_t cl) {
     for(int i = 0; i < 100; i++){
         int which = (random() % 2);
         int arg = (random() % 1000);
-        int rep;
+        int rep = -1;
 
         auto start = steady_clock::now();
 
@@ -338,6 +342,7 @@ static void failure_test() {
 }
 
 int main(int argc, char *argv[]) {
+    global = new t4_state('r');
 
     setvbuf(stdout, NULL, _IONBF, 0);
     setvbuf(stderr, NULL, _IONBF, 0);
@@ -390,7 +395,7 @@ int main(int argc, char *argv[]) {
 
     if (isclient) {
         // server's address.
-        dst = "127.0.0.1:" + to_string(port);
+        dst = "127.0.0.1:" + std::to_string(port);
 
 
         // start the client.  bind it to the server.