ib_api_status_t __osmv_txnmgr_remove_txn(IN osmv_txn_mgr_t * p_tx_mgr, IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn) { cl_map_obj_t *p_obj; cl_map_item_t *p_item; OSM_LOG_ENTER(p_tx_mgr->p_log); CL_ASSERT(p_tx_mgr); CL_ASSERT(pp_txn); p_item = cl_qmap_remove(p_tx_mgr->p_txn_map, key); if (p_item == cl_qmap_end(p_tx_mgr->p_txn_map)) { osm_log(p_tx_mgr->p_log, OSM_LOG_ERROR, "__osmv_txnmgr_remove_txn: ERR 6701: " "Could not remove the transaction 0x%llX - " "something is really wrong!\n", key); OSM_LOG_EXIT(p_tx_mgr->p_log); return IB_NOT_FOUND; } p_obj = PARENT_STRUCT(p_item, cl_map_obj_t, item); *pp_txn = cl_qmap_obj(p_obj); free(p_obj); OSM_LOG_EXIT(p_tx_mgr->p_log); return IB_SUCCESS; }
void osmv_txn_abort_rmpp_txns(osm_bind_handle_t h_bind) { osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind; cl_map_item_t *p_item; cl_map_obj_t *p_obj; osmv_txn_ctx_t *p_txn; osmv_rmpp_send_ctx_t *p_send_ctx; cl_qmap_t *p_map = p_bo->txn_mgr.p_txn_map; OSM_LOG_ENTER(p_bo->p_vendor->p_log); while (FALSE == cl_is_qmap_empty(p_map)) { p_item = cl_qmap_head(p_map); p_obj = PARENT_STRUCT(p_item, cl_map_obj_t, item); p_txn = (osmv_txn_ctx_t *) cl_qmap_obj(p_obj); p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn); if (NULL != p_send_ctx) { p_send_ctx->status = IB_INTERRUPTED; /* Wake up the sender thread to let it break out */ cl_event_signal(&p_send_ctx->event); } cl_qmap_remove_item(p_map, p_item); } OSM_LOG_EXIT(p_bo->p_vendor->p_log); }
ib_api_status_t __osmv_txnmgr_lookup(IN osmv_txn_mgr_t * p_tx_mgr, IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn) { ib_api_status_t status = IB_SUCCESS; cl_map_item_t *p_item; cl_map_obj_t *p_obj; uint64_t tmp_key; OSM_LOG_ENTER(p_tx_mgr->p_log); CL_ASSERT(p_tx_mgr); CL_ASSERT(pp_txn); osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG, "__osmv_txnmgr_lookup: " "Looking for key: 0x%llX in map ptr:%p\n", key, p_tx_mgr->p_txn_map); p_item = cl_qmap_head(p_tx_mgr->p_txn_map); while (p_item != cl_qmap_end(p_tx_mgr->p_txn_map)) { tmp_key = cl_qmap_key(p_item); osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG, "__osmv_txnmgr_lookup: " "Found key 0x%llX \n", tmp_key); p_item = cl_qmap_next(p_item); } p_item = cl_qmap_get(p_tx_mgr->p_txn_map, key); if (cl_qmap_end(p_tx_mgr->p_txn_map) == p_item) { status = IB_NOT_FOUND; } else { p_obj = PARENT_STRUCT(p_item, cl_map_obj_t, item); *pp_txn = cl_qmap_obj(p_obj); } OSM_LOG_EXIT(p_tx_mgr->p_log); return status; }
void __osmv_txn_all_done(osm_bind_handle_t h_bind) { osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind; cl_map_item_t *p_item; cl_map_obj_t *p_obj; osmv_txn_ctx_t *p_txn; OSM_LOG_ENTER(p_bo->p_vendor->p_log); p_item = cl_qmap_head(p_bo->txn_mgr.p_txn_map); while (p_item != cl_qmap_end(p_bo->txn_mgr.p_txn_map)) { p_obj = PARENT_STRUCT(p_item, cl_map_obj_t, item); p_txn = (osmv_txn_ctx_t *) cl_qmap_obj(p_obj); osmv_txn_done(h_bind, osmv_txn_get_key(p_txn), FALSE); free(p_obj); /* assuming osmv_txn_done has removed the txn from the map */ p_item = cl_qmap_head(p_bo->txn_mgr.p_txn_map); } OSM_LOG_EXIT(p_bo->p_vendor->p_log); }
Status_t sm_routing_makeModule(const char * name, RoutingModule_t ** module) { cl_map_item_t * it; *module = NULL; if (name == NULL || strlen(name) == 0) return VSTATUS_ILLPARM; if ((it = cl_qmap_get(&moduleFacMap, UGLY_CHAR_U64(name))) == cl_qmap_end(&moduleFacMap)) return VSTATUS_BAD; routing_mod_factory fac = cl_qmap_obj((const cl_map_obj_t * const) it); Status_t s; if ((s = vs_pool_alloc(&sm_pool, sizeof(RoutingModule_t), (void*)module)) != VSTATUS_OK) { return s; } memset(*module, 0, sizeof(RoutingModule_t)); return fac(*module); }