Skip to content

Commit

Permalink
Merge pull request #642 from openziti/avoid-channel-reconnect-on-close
Browse files Browse the repository at this point in the history
avoid starting reconnect if channel is closed on purpose
  • Loading branch information
ekoby authored Apr 3, 2024
2 parents 0887241 + 94bb355 commit 56dd6f9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions library/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void on_channel_send(uv_write_t *w, int status) {

if (status < 0) {
CH_LOG(ERROR, "write failed [%d/%s]", status, uv_strerror(status));
on_channel_close(ch, ZITI_GATEWAY_UNAVAILABLE, status);
on_channel_close(ch, ZITI_CONNABORT, status);
}

free(w);
Expand Down Expand Up @@ -821,6 +821,10 @@ static void on_channel_close(ziti_channel_t *ch, int ziti_err, ssize_t uv_err) {
ch->in_next = NULL;
}

if (ziti_err == ZITI_DISABLED || ziti_err == ZITI_GATEWAY_UNAVAILABLE) {
return;
}

if (ch->state != Closed) {
if (uv_err == UV_EOF) {
ZTX_LOG(VERBOSE, "edge router closed connection, trying to refresh api session");
Expand Down Expand Up @@ -864,7 +868,7 @@ static void on_channel_data(uv_stream_t *s, ssize_t len, const uv_buf_t *buf) {
default:
CH_LOG(INFO, "channel disconnected [%zd/%s]", len, uv_strerror(len));
// propagate close
on_channel_close(ch, ZITI_GATEWAY_UNAVAILABLE, len);
on_channel_close(ch, ZITI_CONNABORT, len);
close_connection(ch);
break;
}
Expand Down

0 comments on commit 56dd6f9

Please sign in to comment.