projects
/
invirt/third/libt4.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Working on g++ compatibility
[invirt/third/libt4.git]
/
rpc
/
rpctest.cc
diff --git
a/rpc/rpctest.cc
b/rpc/rpctest.cc
index
1963ada
..
4dd2af2
100644
(file)
--- a/
rpc/rpctest.cc
+++ b/
rpc/rpctest.cc
@@
-6,15
+6,16
@@
#include <arpa/inet.h>
#include <getopt.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <getopt.h>
#include <unistd.h>
+#include <string.h>
#define NUM_CL 2
char log_thread_prefix = 'r';
#define NUM_CL 2
char log_thread_prefix = 'r';
-rpcs *server; // server rpc object
-rpcc *clients[NUM_CL]; // client rpc object
-string dst; //server's ip address
-in_port_t port;
+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;
// server-side handlers. they must be methods of some class
// to simplify rpcs::reg(). a server process can have handlers
// server-side handlers. they must be methods of some class
// to simplify rpcs::reg(). a server process can have handlers
@@
-60,11
+61,11
@@
int srv::handle_slow(int &r, const int a) {
}
int srv::handle_bigrep(string &r, const size_t len) {
}
int srv::handle_bigrep(string &r, const size_t len) {
- r = string((size_t)len, 'x');
+ r = string(len, 'x');
return 0;
}
return 0;
}
-srv service;
+static srv service;
void startserver() {
server = new rpcs(port);
void startserver() {
server = new rpcs(port);
@@
-82,13
+83,15
@@
void testmarshall() {
VERIFY(((string)m).size()==rpc_protocol::RPC_HEADER_SZ);
int i = 12345;
unsigned long long l = 1223344455L;
VERIFY(((string)m).size()==rpc_protocol::RPC_HEADER_SZ);
int i = 12345;
unsigned long long l = 1223344455L;
+ size_t sz = 101010101;
string s = "hallo....";
m << i;
m << l;
m << s;
string s = "hallo....";
m << i;
m << l;
m << s;
+ m << sz;
string b = m;
string b = m;
- VERIFY(b.size() == rpc_protocol::RPC_HEADER_SZ+sizeof(i)+sizeof(l)+s.size()+sizeof(int));
+ VERIFY(b.size() == rpc_protocol::RPC_HEADER_SZ+sizeof(i)+sizeof(l)+s.size()+sizeof(int)+sizeof(uint32_t));
unmarshall un(b, true);
rpc_protocol::request_header rh1;
unmarshall un(b, true);
rpc_protocol::request_header rh1;
@@
-97,11
+100,13
@@
void testmarshall() {
int i1;
unsigned long long l1;
string s1;
int i1;
unsigned long long l1;
string s1;
+ size_t sz1;
un >> i1;
un >> l1;
un >> s1;
un >> i1;
un >> l1;
un >> s1;
+ un >> sz1;
VERIFY(un.okdone());
VERIFY(un.okdone());
- VERIFY(i1==i && l1==l && s1==s);
+ VERIFY(i1==i && l1==l && s1==s && sz1==sz);
}
void client1(size_t cl) {
}
void client1(size_t cl) {
@@
-199,6
+204,7
@@
void simple_tests(rpcc *c) {
// huge RPC
string big(1000000, 'x');
intret = c->call(srv_protocol::_22, rep, big, (string)"z");
// huge RPC
string big(1000000, 'x');
intret = c->call(srv_protocol::_22, rep, big, (string)"z");
+ VERIFY(intret == 0);
VERIFY(rep.size() == 1000001);
cout << " -- huge 1M rpc request .. ok" << endl;
VERIFY(rep.size() == 1000001);
cout << " -- huge 1M rpc request .. ok" << endl;