diff --git a/src/box/box.cc b/src/box/box.cc index ba2f6b1980dc79e2e6ccc9186dfa3ac072c9f0b3..8e601a268c6455cc6f3adf05c081f5849b0d9fb4 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -1704,13 +1704,13 @@ box_promote(void) return rc; } -void +int box_listen(void) { const char *uri = cfg_gets("listen"); - if (box_check_uri(uri, "listen") != 0) - diag_raise(); - iproto_listen(uri); + if (box_check_uri(uri, "listen") != 0 || iproto_listen(uri) != 0) + return -1; + return 0; } void @@ -3120,7 +3120,8 @@ bootstrap(const struct tt_uuid *instance_uuid, * Begin listening on the socket to enable * master-master replication leader election. */ - box_listen(); + if (box_listen() != 0) + diag_raise(); /* * Wait for the cluster to start up. * @@ -3206,7 +3207,8 @@ local_recovery(const struct tt_uuid *instance_uuid, say_info("instance vclock %s", vclock_to_string(&replicaset.vclock)); if (wal_dir_lock >= 0) { - box_listen(); + if (box_listen() != 0) + diag_raise(); box_sync_replication(false); struct replica *master; @@ -3284,7 +3286,8 @@ local_recovery(const struct tt_uuid *instance_uuid, * applied in hot standby mode. */ vclock_copy(&replicaset.vclock, &recovery->vclock); - box_listen(); + if (box_listen() != 0) + diag_raise(); box_sync_replication(false); } stream_guard.is_active = false; diff --git a/src/box/box.h b/src/box/box.h index 04bdd397d11ac119adb827dde42efe2c474fe161..ecf32240dfbbfce003dec8b638f060098bf1daaf 100644 --- a/src/box/box.h +++ b/src/box/box.h @@ -231,7 +231,7 @@ box_process_vote(struct ballot *ballot); void box_check_config(void); -void box_listen(void); +int box_listen(void); void box_set_replication(void); void box_set_log_level(void); void box_set_log_format(void); diff --git a/src/box/iproto.cc b/src/box/iproto.cc index bbafbe9a069f89946bf84b8ae4c982d2ccd25e43..8898b6bb705cc640c9b3b4fb091a9d2aab4cea52 100644 --- a/src/box/iproto.cc +++ b/src/box/iproto.cc @@ -2424,41 +2424,48 @@ iproto_do_cfg_f(struct cbus_call_msg *m) return 0; } -static inline void +static inline int iproto_do_cfg(struct iproto_thread *iproto_thread, struct iproto_cfg_msg *msg) { msg->iproto_thread = iproto_thread; if (cbus_call(&iproto_thread->net_pipe, &iproto_thread->tx_pipe, msg, iproto_do_cfg_f, NULL, TIMEOUT_INFINITY) != 0) - diag_raise(); + return -1; + return 0; } -static inline void +static inline int iproto_send_stop_msg(void) { struct iproto_cfg_msg cfg_msg; iproto_cfg_msg_create(&cfg_msg, IPROTO_CFG_STOP); for (int i = 0; i < iproto_threads_count; i++) - iproto_do_cfg(&iproto_threads[i], &cfg_msg); + if (iproto_do_cfg(&iproto_threads[i], &cfg_msg) != 0) + return -1; + return 0; } -static inline void +static inline int iproto_send_listen_msg(struct evio_service *binary) { struct iproto_cfg_msg cfg_msg; iproto_cfg_msg_create(&cfg_msg, IPROTO_CFG_LISTEN); cfg_msg.binary = binary; for (int i = 0; i < iproto_threads_count; i++) - iproto_do_cfg(&iproto_threads[i], &cfg_msg); + if (iproto_do_cfg(&iproto_threads[i], &cfg_msg) != 0) + return -1; + return 0; } -void +int iproto_listen(const char *uri) { struct evio_service binary; memset(&binary, 0, sizeof(binary)); - iproto_send_stop_msg(); + if (iproto_send_stop_msg() != 0) + return -1; + if (uri != NULL) { /* * Please note, we bind socket in main thread, and then @@ -2467,12 +2474,14 @@ iproto_listen(const char *uri) * incoming connections across iproto threads. */ if (evio_service_bind(&binary, uri) != 0) - diag_raise(); - iproto_send_listen_msg(&binary); + return -1; + if (iproto_send_listen_msg(&binary) != 0) + return -1; } iproto_bound_address_storage = binary.addrstorage; iproto_bound_address_len = binary.addr_len; + return 0; } size_t @@ -2557,7 +2566,8 @@ iproto_set_msg_max(int new_iproto_msg_max) iproto_cfg_msg_create(&cfg_msg, IPROTO_CFG_MSG_MAX); cfg_msg.iproto_msg_max = new_iproto_msg_max; for (int i = 0; i < iproto_threads_count; i++) { - iproto_do_cfg(&iproto_threads[i], &cfg_msg); + if (iproto_do_cfg(&iproto_threads[i], &cfg_msg) != 0) + diag_raise(); cpipe_set_max_input(&iproto_threads[i].net_pipe, new_iproto_msg_max / 2); } diff --git a/src/box/iproto.h b/src/box/iproto.h index d360f65e4afa77af250246c0514e7ea2110cc866..b7ebf9a0e8046f59d56ff95712ed36dd73721be4 100644 --- a/src/box/iproto.h +++ b/src/box/iproto.h @@ -96,7 +96,7 @@ iproto_rmean_foreach(void *cb, void *cb_ctx); void iproto_init(int threads_count); -void +int iproto_listen(const char *uri); void diff --git a/src/box/lua/cfg.cc b/src/box/lua/cfg.cc index 1142e27261eec024b6a60d3c649350e9c7d58e6a..e0c5a400219c8bb2524e805cceed95aa52cfb99e 100644 --- a/src/box/lua/cfg.cc +++ b/src/box/lua/cfg.cc @@ -68,11 +68,8 @@ lbox_cfg_load(struct lua_State *L) static int lbox_cfg_set_listen(struct lua_State *L) { - try { - box_listen(); - } catch (Exception *) { + if (box_listen() != 0) luaT_error(L); - } return 0; }