Add a protocol callback for a cleanup step before the requests are done.
This allows cleaning up writer state and thereby avoids segfaults when
buckets are destroyed out of order.

This should solve a segfault/abort() in the Subversion over H2 issue I'm
debugging.

* incoming.c
  (serf_incoming_set_framing_type,
   serf_incoming_create2): Hook pre teardown.

* outgoing.c
  (reset_connection,
   serf_connection_create,
   serf_connection_close,
   serf_connection_set_framing_type): Hook pre teardown.

* protocols/http2_protocol.c
  (http2_outgoing_pre_teardown,
   http2_incoming_pre_teardown): New prototypes.
  (serf__http2_protocol_init,
   serf__http2_protocol_init_server): Hook teardown.
  (http2_outgoing_pre_teardown,
   http2_incoming_pre_teardown): New function.

* protocols/http2_protocol.h
  (serf_http2__stream_pre_cleanup): New function.

* protocols/http2_stream.c
  (serf_http2__stream_pre_cleanup): New function. Destroy data tail here
    instead of...
  (serf_http2__stream_cleanup): ... here.

* serf_private.h
  (serf_incoming_t,
   serf_connection_t): New callback.


git-svn-id: https://svn.apache.org/repos/asf/serf/trunk@1717013 13f79535-47bb-0310-9956-ffa450edef68
6 files changed