Commit 0fb9983f authored by Marek Vavrusa's avatar Marek Vavrusa

daemon/network: allow listening on part of interfaces

when whole interface is passed and some of the addresses are not bindable,
the daemon will print them, but will continue to bind to the rest of the
addresses

fixes #80
parent 85b4355c
...@@ -182,8 +182,7 @@ static int net_listen_iface(lua_State *L, int port) ...@@ -182,8 +182,7 @@ static int net_listen_iface(lua_State *L, int port)
int ret = network_listen(&engine->net, lua_tostring(L, -1), int ret = network_listen(&engine->net, lua_tostring(L, -1),
port, NET_TCP|NET_UDP); port, NET_TCP|NET_UDP);
if (ret != 0) { if (ret != 0) {
format_error(L, kr_strerror(ret)); kr_log_info("[system] bind to '%s#%d' %s\n", lua_tostring(L, -1), port, kr_strerror(ret));
lua_error(L);
} }
lua_pop(L, 1); lua_pop(L, 1);
} }
......
...@@ -80,6 +80,9 @@ static struct session *session_borrow(struct worker_ctx *worker) ...@@ -80,6 +80,9 @@ static struct session *session_borrow(struct worker_ctx *worker)
static void session_release(struct worker_ctx *worker, struct session *s) static void session_release(struct worker_ctx *worker, struct session *s)
{ {
if (!s) {
return;
}
if (worker->pool_sessions.len < MP_FREELIST_SIZE) { if (worker->pool_sessions.len < MP_FREELIST_SIZE) {
session_clear(s); session_clear(s);
array_push(worker->pool_sessions, s); array_push(worker->pool_sessions, s);
......
...@@ -135,6 +135,7 @@ static int open_endpoint(struct network *net, struct endpoint *ep, struct sockad ...@@ -135,6 +135,7 @@ static int open_endpoint(struct network *net, struct endpoint *ep, struct sockad
if (!ep->udp) { if (!ep->udp) {
return kr_error(ENOMEM); return kr_error(ENOMEM);
} }
memset(ep->udp, 0, sizeof(*ep->udp));
handle_init(udp, net->loop, ep->udp, sa->sa_family); handle_init(udp, net->loop, ep->udp, sa->sa_family);
int ret = udp_bind(ep->udp, sa); int ret = udp_bind(ep->udp, sa);
if (ret != 0) { if (ret != 0) {
...@@ -147,6 +148,7 @@ static int open_endpoint(struct network *net, struct endpoint *ep, struct sockad ...@@ -147,6 +148,7 @@ static int open_endpoint(struct network *net, struct endpoint *ep, struct sockad
if (!ep->tcp) { if (!ep->tcp) {
return kr_error(ENOMEM); return kr_error(ENOMEM);
} }
memset(ep->tcp, 0, sizeof(*ep->tcp));
handle_init(tcp, net->loop, ep->tcp, sa->sa_family); handle_init(tcp, net->loop, ep->tcp, sa->sa_family);
int ret = tcp_bind(ep->tcp, sa); int ret = tcp_bind(ep->tcp, sa);
if (ret != 0) { if (ret != 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment