beam->aborted = 1;
if (c == beam->from) {
/* sender aborts */
+ if (beam->send_cb) {
+ beam->send_cb(beam->send_ctx, beam);
+ }
if (beam->was_empty_cb && buffer_is_empty(beam)) {
beam->was_empty_cb(beam->was_empty_ctx, beam);
}
* Trigger event callbacks, so receiver can know there is something
* to receive before we do a conditional wait. */
purge_consumed_buckets(beam);
+ if (beam->send_cb) {
+ beam->send_cb(beam->send_ctx, beam);
+ }
if (was_empty && beam->was_empty_cb) {
beam->was_empty_cb(beam->was_empty_ctx, beam);
}
}
}
+ if (beam->send_cb && !buffer_is_empty(beam)) {
+ beam->send_cb(beam->send_ctx, beam);
+ }
if (was_empty && beam->was_empty_cb && !buffer_is_empty(beam)) {
beam->was_empty_cb(beam->was_empty_ctx, beam);
}
apr_thread_mutex_unlock(beam->lock);
}
+void h2_beam_on_send(h2_bucket_beam *beam,
+ h2_beam_ev_callback *send_cb, void *ctx)
+{
+ apr_thread_mutex_lock(beam->lock);
+ beam->send_cb = send_cb;
+ beam->send_ctx = ctx;
+ apr_thread_mutex_unlock(beam->lock);
+}
+
void h2_beam_on_was_empty(h2_bucket_beam *beam,
h2_beam_ev_callback *was_empty_cb, void *ctx)
{
void *was_empty_ctx;
h2_beam_ev_callback *recv_cb; /* event: buckets were transfered in h2_beam_receive() */
void *recv_ctx;
+ h2_beam_ev_callback *send_cb; /* event: buckets were added in h2_beam_send() */
+ void *send_ctx;
apr_off_t recv_bytes; /* amount of bytes transferred in h2_beam_receive() */
apr_off_t recv_bytes_reported; /* amount of bytes reported as received via callback */
void h2_beam_on_received(h2_bucket_beam *beam,
h2_beam_ev_callback *recv_cb, void *ctx);
+/**
+ * Register a call back from the sender side to be invoked when send
+ * has added buckets to the beam.
+ * Unregister by passing a NULL on_send_cb.
+ * @param beam the beam to set the callback on
+ * @param on_send_cb the callback to invoke after buckets were added
+ * @param ctx the context to use in callback invocation
+ */
+void h2_beam_on_send(h2_bucket_beam *beam,
+ h2_beam_ev_callback *on_send_cb, void *ctx);
+
/**
* Register a call back from the sender side to be invoked when send
* has added to a previously empty beam.
h2_beam_on_was_empty(c2_ctx->beam_out, NULL, NULL);
}
if (c2_ctx->beam_in) {
+ h2_beam_on_send(c2_ctx->beam_in, NULL, NULL);
h2_beam_on_received(c2_ctx->beam_in, NULL, NULL);
h2_beam_on_consumed(c2_ctx->beam_in, NULL, NULL);
}
if (stream->input) {
conn_ctx->beam_in = stream->input;
- h2_beam_on_was_empty(stream->input, c2_beam_input_write_notify, c2);
+ h2_beam_on_send(stream->input, c2_beam_input_write_notify, c2);
h2_beam_on_received(stream->input, c2_beam_input_read_notify, c2);
h2_beam_on_consumed(stream->input, c1_input_consumed, stream);
}