/* ===================================================== */ void handle_message( const connection_ptr& con, const message& m ) { try { chan_data& cdat = get_channel_data(con); ilog( "${msg_type}", ("msg_type", (bitname::message_type)m.msg_type ) ); switch( (bitname::message_type)m.msg_type ) { case name_inv_msg: handle_name_inv( con, cdat, m.as<name_inv_message>() ); break; case block_inv_msg: handle_block_inv( con, cdat, m.as<block_inv_message>() ); break; case get_name_inv_msg: handle_get_name_inv( con, cdat, m.as<get_name_inv_message>() ); break; case get_headers_msg: handle_get_headers( con, cdat, m.as<get_headers_message>() ); break; case get_block_msg: handle_get_block( con, cdat, m.as<get_block_message>() ); break; case get_block_index_msg: handle_get_block_index( con, cdat, m.as<get_block_index_message>() ); break; case get_name_header_msg: handle_get_name( con, cdat, m.as<get_name_header_message>() ); break; case name_header_msg: handle_name( con, cdat, m.as<name_header_message>() ); break; case block_index_msg: handle_block_index( con, cdat, m.as<block_index_message>() ); break; case block_msg: handle_block( con, cdat, m.as<block_message>() ); break; case headers_msg: handle_headers( con, cdat, m.as<headers_message>() ); break; default: FC_THROW_EXCEPTION( exception, "unknown bitname message type ${msg_type}", ("msg_type", m.msg_type ) ); } } catch ( fc::exception& e ) { wlog( "${e} ${from}", ("e",e.to_detail_string())("from",con->remote_endpoint()) ); } } // handle_message
int Connection::on_readable() { while (1) { if (mreq_ == NULL && init_block() < 0) { return -1; } int rstat, retval; if ((rstat = do_read()) == RR_ERROR) { return -1; } if ((retval = handle_block()) < 0) { return -1; } if (rstat == RR_MAY_MORE) { continue; } else if (rstat == RR_CLOSED_BY_PEER) { return -1; } else { return 0; } } // can not reach here assert(0); return 0; }
bool des::event_simulation::run() { if( events.size() == 0 ) return false; timer_control.set( events.peek().get_time() ); while( // handle all events at the next time stamp events.size() > 0 && events.peek().get_time() == timer() ) { event e = events.pop(); e.get_process()->transition( e.get_transition() ); switch( e.get_transition() ) { case prc::DISPATCH: throw std::logic_error("DISPATCH found in event queue"); case prc::PREEMPT: handle_preempt(e.get_process()); break; case prc::BLOCK: handle_block(e.get_process()); break; case prc::UNBLOCK: handle_unblock(e.get_process()); break; case prc::ARRIVE: handle_arrive(e.get_process()); break; case prc::FINISH: handle_finish(e.get_process()); break; } } // if scheduler not busy, dispatch a process and create an event upon its return if( timer() >= busy_until ) { auto res = sched->dispatch(); process *p = res.first; if( p ) { busy_until = timer() + res.second.second; total_cpu_on += res.second.second; prc::state_transition upon_end_of_execution = res.second.first; switch( upon_end_of_execution ) { case prc::FINISH: case prc::BLOCK: case prc::PREEMPT: events.push(busy_until, p, upon_end_of_execution); break; default: throw std::logic_error("Dispatched process returned in an unexpected state"); } } } return true; }
memerr _essl_rewrite_sampler_accesses(pass_run_context *pr_ctx, symbol *func) { rewrite_sampler_accesses_context ctx; unsigned int i; ctx.pool = pr_ctx->pool; ctx.cfg = func->control_flow_graph; ctx.typestor_ctx = pr_ctx->ts_ctx; ESSL_CHECK(_essl_ptrset_init(&ctx.visited, pr_ctx->tmp_pool)); for (i = 0 ; i < ctx.cfg->n_blocks ; i++) { ESSL_CHECK(handle_block(&ctx, ctx.cfg->postorder_sequence[i])); } return MEM_OK; }
static void handle_blk32(char *s) { handle_block(s,32); }
static void handle_blk16(char *s) { handle_block(s,16); }
static void handle_blk8(char *s) { handle_block(s,8); }
static int demux_mkv_read_block(FILE *s, mkv_demuxer_t *mkv_d) { uint64_t length, l; int il, tmp; uint64_t block_duration = 0, block_length = 0; int64_t block_bref = 0, block_fref = 0; uint8_t *block = NULL; length = ebml_read_length (s, NULL); while (length > 0) { switch (ebml_read_id (s, &il)) { case MATROSKA_ID_BLOCKDURATION: //puts("MATROSKA_ID_BLOCKDURATION"); block_duration = ebml_read_uint (s, &l); if (block_duration == EBML_UINT_INVALID) { if(block) free(block); return 0; } block_duration *= mkv_d->tc_scale / 1000000.0; break; case MATROSKA_ID_BLOCK: //puts("MATROSKA_ID_BLOCK"); block_length = ebml_read_length (s, &tmp); if(block) free(block); if (block_length > SIZE_MAX - AV_LZO_INPUT_PADDING) return 0; block = (uint8_t *)malloc (block_length + AV_LZO_INPUT_PADDING); if (!block) { return 0; } if (fread(block, 1, (size_t)block_length, s) != (size_t) block_length) { if(block) free(block); return 0; } l = tmp + block_length; break; case MATROSKA_ID_REFERENCEBLOCK: //puts("MATROSKA_ID_REFERENCEBLOCK"); { int64_t num = ebml_read_int (s, &l); if (num == EBML_INT_INVALID) { if(block) free(block); return 0; } if (num <= 0) block_bref = num; else block_fref = num; break; } case EBML_ID_INVALID: //puts("EBML_ID_INVALID"); if(block) free(block); return 0; default: ebml_read_skip (s, &l); break; } length -= l + il; if (block) { handle_block (mkv_d, block, block_length, block_duration, block_bref, block_fref, 0); free (block); block = NULL; } } return 0; }