void osm_transaction_mgr_destroy(IN osm_vendor_t * const p_vend) { osm_transaction_mgr_t *trans_mgr_p; cl_list_item_t *p_list_item; cl_map_item_t *p_map_item; osm_madw_req_t *osm_madw_req_p; OSM_LOG_ENTER(p_vend->p_log); trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr; if (p_vend->p_transaction_mgr != NULL) { /* we need to get a lock */ cl_spinlock_acquire(&trans_mgr_p->transaction_mgr_lock); /* go over all the items in the list and remove them */ p_list_item = cl_qlist_remove_head(trans_mgr_p->madw_reqs_list_p); while (p_list_item != cl_qlist_end(trans_mgr_p->madw_reqs_list_p)) { osm_madw_req_p = (osm_madw_req_t *) p_list_item; if (osm_madw_req_p->p_madw->p_mad) osm_log(p_vend->p_log, OSM_LOG_DEBUG, "osm_transaction_mgr_destroy: " "Found outstanding MADW:%p TID:<0x%" PRIx64 ">.\n", osm_madw_req_p->p_madw, osm_madw_req_p->p_madw->p_mad-> trans_id); else osm_log(p_vend->p_log, OSM_LOG_DEBUG, "osm_transaction_mgr_destroy: " "Found outstanding MADW:%p TID:UNDEFINED.\n", osm_madw_req_p->p_madw); /* each item - remove it from the map */ p_map_item = &(osm_madw_req_p->map_item); cl_qmap_remove_item(trans_mgr_p->madw_by_tid_map_p, p_map_item); /* free the item */ free(osm_madw_req_p); p_list_item = cl_qlist_remove_head(trans_mgr_p->madw_reqs_list_p); } /* free the qlist and qmap */ free(trans_mgr_p->madw_reqs_list_p); free(trans_mgr_p->madw_by_tid_map_p); /* reliease and destroy the lock */ cl_spinlock_release(&trans_mgr_p->transaction_mgr_lock); cl_spinlock_destroy(&(trans_mgr_p->transaction_mgr_lock)); /* destroy the timer */ cl_timer_trim(&trans_mgr_p->madw_list_timer, 1); cl_timer_destroy(&trans_mgr_p->madw_list_timer); /* free the transaction_manager object */ free(trans_mgr_p); trans_mgr_p = NULL; } OSM_LOG_EXIT(p_vend->p_log); }
static int load_svcr(osm_opensm_t * p_osm, ib_service_record_t * sr, uint32_t modified_time, uint32_t lease_period) { osm_svcr_t *p_svcr; int ret = 0; cl_plock_excl_acquire(&p_osm->lock); if (osm_svcr_get_by_rid(&p_osm->subn, &p_osm->log, sr)) { OSM_LOG(&p_osm->log, OSM_LOG_VERBOSE, "ServiceRecord already exists\n"); goto _out; } if (!(p_svcr = osm_svcr_new(sr))) { OSM_LOG(&p_osm->log, OSM_LOG_ERROR, "cannot allocate new service struct\n"); ret = -1; goto _out; } p_svcr->modified_time = modified_time; p_svcr->lease_period = lease_period; OSM_LOG(&p_osm->log, OSM_LOG_DEBUG, "adding ServiceRecord...\n"); osm_svcr_insert_to_db(&p_osm->subn, &p_osm->log, p_svcr); if (lease_period != 0xffffffff) cl_timer_trim(&p_osm->sa.sr_timer, 1000); _out: cl_plock_release(&p_osm->lock); return ret; }