void RO6DTxn::start_ro( const RequestHeader &header, const std::vector<mdb::Value> &input, std::vector<mdb::Value> &output, rrr::DeferredReply *defer ) { // RCCDTxn::start_ro(header, input, output, defer); conflict_txns_.clear(); auto txn_handler_pair = TxnRegistry::get(header.t_type, header.p_type); int output_size = 300; output.resize(output_size); int res; phase_ = 1; txn_handler_pair.txn_handler(this, header, input.data(), input.size(), &res, output.data(), &output_size, NULL); // get conflicting transactions std::vector<TxnInfo*> &conflict_txns = conflict_txns_; // TODO callback: read the value and return. std::function<void(void)> cb = [&header, &input, &output, defer, this] () { int res; int output_size = 300; this->phase_ = 2; auto txn_handler_pair = TxnRegistry::get(header.t_type, header.p_type); txn_handler_pair.txn_handler(this, header, input.data(), input.size(), &res, output.data(), &output_size, NULL); output.resize(output_size); defer->reply(); }; // wait for them become commit. DragonBall *ball = new DragonBall(conflict_txns.size() + 1, cb); for (auto tinfo: conflict_txns) { tinfo->register_event(TXN_DCD, ball); } ball->trigger(); // TODO: for Shuai, this does everything read transactions need in // start phase. See the comments to its declaration in dtxn.hpp // It needs txn_id, row, and column_id for this txn, please implement the // interface for that. // This function also returns the value for this read, since read txn returns // value in start phase (no commit phase). So please also handle the return type // of start_ro // comment it out for now for compiling /*Value result = do_ro(txn_id, &row, col_id);*/ }
static int ssn_handler(TSCont contp, TSEvent event, void *edata) { TSHttpSsn ssnp; TSHttpTxn txnp; switch (event) { case TS_EVENT_HTTP_SSN_START: ssnp = (TSHttpSsn)edata; handle_session(ssnp, contp); TSHttpSsnReenable(ssnp, TS_EVENT_HTTP_CONTINUE); return 0; case TS_EVENT_HTTP_TXN_START: txnp = (TSHttpTxn)edata; txn_handler(txnp, contp); TSHttpTxnReenable(txnp, TS_EVENT_HTTP_CONTINUE); return 0; default: TSDebug("tag_session", "In the default case: event = %d", event); break; } return 0; }