diff options
author | Simon Cornish <zl9d97p02@sneakemail.com> | 2022-03-06 20:54:10 -0800 |
---|---|---|
committer | Simon Cornish <zl9d97p02@sneakemail.com> | 2022-03-06 20:54:45 -0800 |
commit | 723116de424261e000d5a2db0aa4628c56e2e1af (patch) | |
tree | c94fd5260a1751c581094f937b3b180ee82e027e /erts | |
parent | 6d51a2ca8863f374cd1ee8605c100cf68f017161 (diff) | |
download | erlang-723116de424261e000d5a2db0aa4628c56e2e1af.tar.gz |
Ensure driver always returns {ok,AssocId}
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/drivers/common/inet_drv.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c index f44f7a0693..b0e8d5ee30 100644 --- a/erts/emulator/drivers/common/inet_drv.c +++ b/erts/emulator/drivers/common/inet_drv.c @@ -2337,6 +2337,14 @@ static int async_ok_assoc_id(inet_descriptor* desc, sctp_assoc_t assoc_id) return erl_drv_send_term(desc->dport, caller, spec, i); } + +static int async_ok_maybe_assoc_id(inet_descriptor* desc, sctp_assoc_t *p_assoc_id) +{ + if (p_assoc_id) + return async_ok_assoc_id(desc, *p_assoc_id); + else + return async_ok(desc); +} #endif static int async_ok_port(inet_descriptor* desc, ErlDrvTermData Port2) @@ -12643,6 +12651,7 @@ static ErlDrvSSizeT packet_inet_ctl(ErlDrvData e, unsigned int cmd, char* buf, #ifdef HAVE_SCTP unsigned timeout; sctp_assoc_t assoc_id = 0; + sctp_assoc_t *p_assoc_id = NULL; #endif DEBUGF(("packet_inet_ctl(%p): CONNECT\r\n", desc->port)); @@ -12691,7 +12700,8 @@ static ErlDrvSSizeT packet_inet_ctl(ErlDrvData e, unsigned int cmd, char* buf, memcpy(rabuf, &remote, remote_size); rabuf += remote_size; } - code = p_sctp_connectx(desc->s, addrs, addrcnt, &assoc_id); + p_assoc_id = &assoc_id; + code = p_sctp_connectx(desc->s, addrs, addrcnt, p_assoc_id); FREE((char *)addrs); } else { return ctl_error(EINVAL, rbuf, rsize); @@ -12710,15 +12720,11 @@ static ErlDrvSSizeT packet_inet_ctl(ErlDrvData e, unsigned int cmd, char* buf, if (timeout != INET_INFINITY) driver_set_timer(desc->port, timeout); enq_async(desc, tbuf, INET_REQ_CONNECT); - if (assoc_id) { - async_ok_assoc_id(desc, assoc_id); - } else { - async_ok(desc); - } + async_ok_maybe_assoc_id(desc, p_assoc_id); } else if (code == 0) { /* OK we are connected */ enq_async(desc, tbuf, INET_REQ_CONNECT); - async_ok(desc); + async_ok_maybe_assoc_id(desc, p_assoc_id); } else { return ctl_error(sock_errno(), rbuf, rsize); |