Skip to content

Commit

Permalink
Hook up onAborted, fix a bunch of quic crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB committed Aug 29, 2022
1 parent 072de98 commit 7f94456
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
19 changes: 12 additions & 7 deletions src/Http3Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace uWS {
// we don't have a way to know EOF?
Http3ResponseData *responseData = (Http3ResponseData *) us_quic_stream_ext(s);

if (responseData) {
if (responseData->onData) {
responseData->onData({data, length}, true);
}

Expand All @@ -32,13 +32,18 @@ namespace uWS {
//printf("Stream opened!\n");

// inplace initialize Http3ResponseData here

new (us_quic_stream_ext(s)) Http3ResponseData();
});
us_quic_socket_context_on_close(context, [](us_quic_socket_t *s) {
printf("Disconnected!\n");

});
us_quic_socket_context_on_stream_writable(context, [](us_quic_stream_t *s) {
// Http3ResponseData *responseData = us_quic_stream_ext(s);
// responseData->onWritable();


});
us_quic_socket_context_on_stream_headers(context, [](us_quic_stream_t *s) {

Expand All @@ -52,19 +57,19 @@ namespace uWS {
contextData->router.getUserData() = {(Http3Response *) s, (Http3Request *) nullptr};
contextData->router.route(upperCasedMethod, "/");


});
us_quic_socket_context_on_open(context, [](us_quic_socket_t *s, int is_client) {
printf("Connection established!\n");
});
us_quic_socket_context_on_stream_close(context, [](us_quic_stream_t *s) {

// Http3ResponseData *responseData = us_quic_stream_ext(s);
// responseData->onAborted();

//printf("Stream closed\n");
Http3ResponseData *responseData = (Http3ResponseData *) us_quic_stream_ext(s);

if (responseData->onAborted) {
responseData->onAborted();
}

// inplace destruct Http3ResponseData here
responseData->~Http3ResponseData();
});

return (Http3Context *) context;
Expand Down
4 changes: 2 additions & 2 deletions src/Http3ResponseData.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
namespace uWS {
struct Http3ResponseData {

MoveOnlyFunction<void()> onAborted;
MoveOnlyFunction<void(std::string_view, bool)> onData;
MoveOnlyFunction<void()> onAborted = nullptr;
MoveOnlyFunction<void(std::string_view, bool)> onData = nullptr;

// hasWrittenStatus

Expand Down

0 comments on commit 7f94456

Please sign in to comment.