rpc_set_error(rpc, "rpc_service: POLLERR, "
"Unknown socket error.");
}
- rpc->connect_cb(rpc, RPC_STATUS_ERROR, rpc->error_string, rpc->connect_data);
+ if (rpc->connect_cb != NULL) {
+ rpc->connect_cb(rpc, RPC_STATUS_ERROR, rpc->error_string, rpc->connect_data);
+ }
return -1;
}
if (revents & POLLHUP) {
rpc_set_error(rpc, "Socket failed with POLLHUP");
- rpc->connect_cb(rpc, RPC_STATUS_ERROR, rpc->error_string, rpc->connect_data);
+ if (rpc->connect_cb != NULL) {
+ rpc->connect_cb(rpc, RPC_STATUS_ERROR, rpc->error_string, rpc->connect_data);
+ }
return -1;
}
rpc_set_error(rpc, "rpc_service: socket error "
"%s(%d) while connecting.",
strerror(err), err);
- rpc->connect_cb(rpc, RPC_STATUS_ERROR,
+ if (rpc->connect_cb != NULL) {
+ rpc->connect_cb(rpc, RPC_STATUS_ERROR,
NULL, rpc->connect_data);
+ }
return -1;
}
rpc->is_connected = 1;
- rpc->connect_cb(rpc, RPC_STATUS_SUCCESS, NULL, rpc->connect_data);
+ if (rpc->connect_cb != NULL) {
+ rpc->connect_cb(rpc, RPC_STATUS_SUCCESS, NULL, rpc->connect_data);
+ }
return 0;
}
}
rpc->is_connected = 1;
+ rpc->connect_cb = NULL;
}
/* disconnect but do not error all PDUs, just move pdus in-flight back to the outqueue and reconnect */