if (!ctx)
return;
+ /* Clean up any headers whose ownership may not have been transferred.
+ * This may happen when connection is abruptly ended (e.g. due to errors while
+ * processing HTTP stream. */
+ while (queue_len(ctx->streams) > 0) {
+ struct http_stream stream = queue_head(ctx->streams);
+ free_headers(stream.headers);
+ if (stream.headers == ctx->headers)
+ ctx->headers = NULL; // to prevent double-free
+ queue_pop(ctx->streams);
+ }
+
http_cleanup_stream(ctx);
- // TODO: queue_pop and check/free all headers (ownership may not have been transferred)
queue_deinit(ctx->streams);
nghttp2_session_del(ctx->h2);
free(ctx);