x exited worker threads).
*/
-#include "types.h"
#include "rpc.h"
-#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <netdb.h>
{
lock ml(chan_m_);
if (!chan_ || chan_->isdead())
- chan_ = connect_to_dst(dst_, this, lossytest_);
+ chan_ = connection::to_dst(dst_, this, lossytest_);
if (chan_)
ch = chan_;
IF_LEVEL(2) LOG("created with nonce " << nonce_);
reg(rpc_const::bind, &rpcs::rpcbind, this);
- dispatchpool_ = new ThrPool(6, false);
+ dispatchpool_ = unique_ptr<thread_pool>(new thread_pool(6, false));
+}
+void rpcs::start() {
char *loss_env = getenv("RPC_LOSSY");
- listener_ = new tcpsconn(this, port_, loss_env ? atoi(loss_env) : 0);
+ listener_ = unique_ptr<tcpsconn>(new tcpsconn(this, port_, loss_env ? atoi(loss_env) : 0));
}
rpcs::~rpcs()
{
// must delete listener before dispatchpool
- delete listener_;
- delete dispatchpool_;
+ listener_ = nullptr;
+ dispatchpool_ = nullptr;
free_reply_window();
}
{
lock pl(procs_m_);
if(procs_.count(proc) < 1){
- cerr << "unknown proc " << hex << proc << "." << endl;
+ LOG("unknown proc 0x" << hex << proc << " with h.srv_nonce=" << h.srv_nonce << ", my srv_nonce=" << nonce_);
VERIFY(0);
return;
}
switch (stat) {
case NEW: // new request
- if (counting_){
+ if (counting_)
updatestat(proc);
- }
rh.ret = (*f)(req, rep);
if (rh.ret == rpc_const::unmarshal_args_failure) {