Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

put outbound close messages on the write queue #540

Merged
merged 2 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions inc_internal/zt_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ struct ziti_write_req_s {
uint8_t *buf;
size_t len;
bool eof;
bool close;

struct message_s *message;
ziti_write_cb cb;
Expand Down
12 changes: 9 additions & 3 deletions library/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,12 @@
conn->write_reqs--;
free(req);
return;
} else if (req->close) {
// conn->state will be set on_disconnect callback
message *m = create_message(conn, ContentTypeStateClosed, 0);
send_message(conn, m, req);
// conn->write_reqs will be decremented and wreq freed in on_write_completed
return;
}

if (req->cb) {
Expand Down Expand Up @@ -615,12 +621,12 @@
case Connected:
case CloseWrite:
case Timedout: {
message *m = create_message(conn, ContentTypeStateClosed, 0);
NEWP(wr, struct ziti_write_req_s);
wr->conn = conn;
wr->close = true;
wr->cb = on_disconnect;
ekoby marked this conversation as resolved.
Show resolved Hide resolved
conn->write_reqs++;
send_message(conn, m, wr);
TAILQ_INSERT_TAIL(&conn->wreqs, wr, _next);
flush_connection(conn);
break;
}

Expand Down Expand Up @@ -836,7 +842,7 @@
}
}

CATCH(crypto) {

Check warning on line 845 in library/connect.c

View workflow job for this annotation

GitHub Actions / Windows x86_64

unreachable code [D:\a\ziti-sdk-c\ziti-sdk-c\build\library\ziti.vcxproj]

Check warning on line 845 in library/connect.c

View workflow job for this annotation

GitHub Actions / Windows ARM64

unreachable code [D:\a\ziti-sdk-c\ziti-sdk-c\build\library\ziti.vcxproj]
FREE(plain_text);
conn_set_state(conn, Disconnected);
conn->data_cb(conn, NULL, ZITI_CRYPTO_FAIL);
Expand Down
Loading