static ib_status_t ib_streamedit_callback( ib_tx_t *tx, ib_server_direction_t dir, off_t start, size_t bytes, const char *repl, size_t repl_len, void *dummy ) { ib_status_t rc; ib_vector_t *edits; edit_t edit; ngxib_req_ctx *ctx = tx->sctx; if (dir == IB_SERVER_REQUEST) { #if 0 edits = ctx->in.edits; if (edits == NULL) { rc = ib_vector_create(&edits, tx->mm, 0); assert((rc == IB_OK) && (edits != NULL)); ctx->in.edits = edits; } #else return IB_ENOTIMPL; #endif } else { edits = ctx->out.edits; if (edits == NULL) { rc = ib_vector_create(&edits, tx->mm, 0); assert((rc == IB_OK) && (edits != NULL)); ctx->out.edits = edits; } } edit.start = start; edit.bytes = bytes; edit.repl = repl; edit.repl_len = repl_len; rc = ib_vector_append(edits, &edit, sizeof(edit_t)); assert(rc == IB_OK); return rc; }
static ib_status_t ib_streamedit_callback( ib_tx_t *tx, ib_server_direction_t dir, off_t start, size_t bytes, const char *repl, size_t repl_len, void *dummy ) { ib_status_t rc; edit_t edit; tsib_txn_ctx *txndata = tx->sctx; tsib_filter_ctx *fctx = (dir == tsib_direction_client_req.dir) ? &txndata->in : &txndata->out; /* Check we're in time to edit this stream */ if (fctx->bytes_done > (size_t)start) { ib_log_error_tx(tx, "Tried to edit data that's already been forwarded"); rc = IB_EINVAL; } else { /* All's well */ if (!fctx->edits) { rc = ib_vector_create(&fctx->edits, tx->mm, 0); assert((rc == IB_OK) && (fctx->edits != NULL)); } edit.start = start; edit.bytes = bytes; edit.repl = repl; edit.repl_len = repl_len; rc = ib_vector_append(fctx->edits, &edit, sizeof(edit_t)); assert(rc == IB_OK); } return rc; }