@@ -1478,12 +1478,22 @@ MHD_http2_session_delete (struct MHD_Connection *connection)
1478
1478
stream = next ;
1479
1479
}
1480
1480
1481
- MHD_pool_destroy (h2 -> pool );
1482
- h2 -> pool = NULL ;
1483
- nghttp2_session_del (h2 -> session );
1484
- free (h2 );
1485
- connection -> h2 = NULL ;
1486
- connection -> state = MHD_CONNECTION_HTTP2_CLOSED ;
1481
+ if (NULL != h2 -> pool )
1482
+ {
1483
+ MHD_pool_destroy (h2 -> pool );
1484
+ h2 -> pool = NULL ;
1485
+ }
1486
+ if (NULL != h2 -> session )
1487
+ {
1488
+ nghttp2_session_del (h2 -> session );
1489
+ h2 -> session = NULL ;
1490
+ }
1491
+ if (NULL != connection -> h2 )
1492
+ {
1493
+ free (h2 );
1494
+ connection -> h2 = NULL ;
1495
+ }
1496
+ connection -> state = MHD_CONNECTION_CLOSED ;
1487
1497
connection -> pool = NULL ;
1488
1498
connection -> read_buffer = NULL ;
1489
1499
connection -> read_buffer_size = 0 ;
@@ -1650,7 +1660,7 @@ MHD_http2_handle_write (struct MHD_Connection *connection)
1650
1660
[connection -> write_buffer_send_offset ],
1651
1661
connection -> write_buffer_append_offset -
1652
1662
connection -> write_buffer_send_offset );
1653
- // ENTER("send_cls ret=%d ", ret);
1663
+ // ENTER("send_cls ret=%ld ", ret);
1654
1664
if (ret < 0 )
1655
1665
{
1656
1666
if (MHD_ERR_AGAIN_ == ret )
@@ -1672,7 +1682,7 @@ MHD_http2_handle_write (struct MHD_Connection *connection)
1672
1682
connection -> write_buffer_append_offset = 0 ;
1673
1683
connection -> write_buffer_send_offset = 0 ;
1674
1684
1675
- /* FILL WRITE BUFFER */
1685
+ /* Fill write buffer */
1676
1686
if (http2_fill_write_buffer (h2 -> session , h2 ) != 0 )
1677
1687
{
1678
1688
MHD_connection_close_ (connection , MHD_REQUEST_TERMINATED_WITH_ERROR );
@@ -1734,7 +1744,10 @@ MHD_http2_handle_idle (struct MHD_Connection *connection)
1734
1744
return MHD_NO ;
1735
1745
}
1736
1746
}
1737
- // ENTER("[id=%zu]", connection->h2->session_id);
1747
+ if (connection -> state == MHD_CONNECTION_HTTP2_CLOSED )
1748
+ return MHD_NO ;
1749
+
1750
+ // ENTER("[id=%d] %s", (connection->h2 ? (int)connection->h2->session_id : -1), MHD_state_to_string (connection->state));
1738
1751
if (connection -> write_buffer_append_offset - connection -> write_buffer_send_offset != 0 )
1739
1752
{
1740
1753
MHD_update_last_activity_ (connection );
@@ -1746,15 +1759,31 @@ MHD_http2_handle_idle (struct MHD_Connection *connection)
1746
1759
}
1747
1760
1748
1761
/* TODO: resume all deferred streams */
1749
- if (connection -> h2 -> deferred_stream > 0 )
1762
+ if (connection -> h2 && connection -> h2 -> deferred_stream > 0 )
1750
1763
{
1751
1764
nghttp2_session_resume_data (connection -> h2 -> session , connection -> h2 -> deferred_stream );
1765
+ struct http2_stream * stream ;
1766
+ stream = nghttp2_session_get_stream_user_data (connection -> h2 -> session , connection -> h2 -> deferred_stream );
1767
+ if (stream == NULL )
1768
+ return 0 ;
1769
+ size_t unused = 0 ;
1770
+ return http2_call_connection_handler (connection , stream , NULL , & unused );
1752
1771
}
1753
1772
1754
1773
return MHD_YES ;
1755
1774
}
1756
1775
1757
1776
1777
+ /**
1778
+ * Suspend handling of network data for the current stream.
1779
+ * @param connection connection to handle
1780
+ */
1781
+ void
1782
+ MHD_http2_suspend_stream (struct MHD_Connection * connection )
1783
+ {
1784
+ connection -> h2 -> deferred_stream = connection -> h2 -> current_stream_id ;
1785
+ }
1786
+
1758
1787
/**
1759
1788
* Queue a response to be transmitted to the client (as soon as
1760
1789
* possible but after #MHD_AccessHandlerCallback returns).
0 commit comments