aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/salticidae/conn.h22
-rw-r--r--include/salticidae/network.h6
2 files changed, 11 insertions, 17 deletions
diff --git a/include/salticidae/conn.h b/include/salticidae/conn.h
index e19ae3a..665e1d5 100644
--- a/include/salticidae/conn.h
+++ b/include/salticidae/conn.h
@@ -59,7 +59,7 @@ class ConnPool {
using conn_t = ArcObj<Conn>;
/** The type of callback invoked when connection status is changed. */
using conn_callback_t = std::function<void(const conn_t &, bool)>;
- using error_callback_t = std::function<void(const std::exception &, bool)>;
+ using error_callback_t = std::function<void(const std::exception_ptr, bool)>;
/** Abstraction for a bi-directional connection. */
class Conn {
friend ConnPool;
@@ -271,13 +271,7 @@ class ConnPool {
void _listen(NetAddr listen_addr);
void recoverable_error(const std::exception_ptr err) const {
user_tcall->async_call([this, err](ThreadCall::Handle &) {
- if (error_cb) {
- try {
- std::rethrow_exception(err);
- } catch (const std::exception &e) {
- error_cb(e, false);
- }
- }
+ if (error_cb) error_cb(err, false);
});
}
@@ -356,14 +350,10 @@ class ConnPool {
disp_ec = workers[0].get_ec();
disp_tcall = workers[0].get_tcall();
workers[0].set_dispatcher();
- disp_error_cb = [this](const std::exception_ptr _err) {
- user_tcall->async_call([this, _err](ThreadCall::Handle &) {
- try {
- std::rethrow_exception(_err);
- } catch (const std::exception &err) {
- stop_workers();
- if (error_cb) error_cb(err, true);
- }
+ disp_error_cb = [this](const std::exception_ptr err) {
+ user_tcall->async_call([this, err](ThreadCall::Handle &) {
+ stop_workers();
+ if (error_cb) error_cb(err, true);
});
disp_ec.stop();
workers[0].stop_tcall();
diff --git a/include/salticidae/network.h b/include/salticidae/network.h
index de7c32e..09b85a0 100644
--- a/include/salticidae/network.h
+++ b/include/salticidae/network.h
@@ -974,9 +974,13 @@ void msgnetwork_terminate(msgnetwork_t *self, const msgnetwork_conn_t *conn);
typedef void (*msgnetwork_msg_callback_t)(const msg_t *, const msgnetwork_conn_t *, void *userdata);
void msgnetwork_reg_handler(msgnetwork_t *self, _opcode_t opcode, msgnetwork_msg_callback_t cb, void *userdata);
-typedef void (*msgnetwork_conn_callback_t)(const msgnetwork_conn_t *, bool, void *userdata);
+typedef void (*msgnetwork_conn_callback_t)(const msgnetwork_conn_t *, bool connected, void *userdata);
void msgnetwork_reg_conn_handler(msgnetwork_t *self, msgnetwork_conn_callback_t cb, void *userdata);
+
+typedef void (*msgnetwork_error_callback_t)(const SalticidaeCError *, bool fatal, void *userdata);
+void msgnetwork_reg_error_handler(msgnetwork_t *self, msgnetwork_error_callback_t cb, void *userdata);
+
msgnetwork_t *msgnetwork_conn_get_net(const msgnetwork_conn_t *conn);
msgnetwork_conn_mode_t msgnetwork_conn_get_mode(const msgnetwork_conn_t *conn);
netaddr_t *msgnetwork_conn_get_addr(const msgnetwork_conn_t *conn);