Free iodevice memory when observer exit
This commit is contained in:
@ -24,43 +24,43 @@ namespace common
|
||||
|
||||
class ObDeviceManager
|
||||
{
|
||||
public:
|
||||
public:
|
||||
const static int MAX_DEVICE_INSTANCE = 20;
|
||||
int init_devices_env();
|
||||
void destroy();
|
||||
static ObDeviceManager &get_instance();
|
||||
|
||||
|
||||
/*for object device, will return a new object to caller*/
|
||||
/*ofs/local will share in upper logical*/
|
||||
int get_device(const common::ObString& storage_info,
|
||||
int get_device(const common::ObString& storage_info,
|
||||
const common::ObString& storage_type_prefix,
|
||||
ObIODevice*& device_handle);
|
||||
int release_device(common::ObIODevice*& device_handle);
|
||||
//for test
|
||||
int64_t get_device_cnt() {return device_count_;}
|
||||
|
||||
|
||||
private:
|
||||
ObDeviceManager();
|
||||
~ObDeviceManager() {}
|
||||
~ObDeviceManager() { destroy(); }
|
||||
|
||||
struct ObDeviceInsInfo {
|
||||
ObIODevice* device_;
|
||||
ObIODevice* device_;
|
||||
char storage_info_[OB_MAX_URI_LENGTH];
|
||||
int64_t ref_cnt_;
|
||||
};
|
||||
|
||||
/*notice:
|
||||
/*notice:
|
||||
int the implement of hashtable, use the assign fun of class to copy key/value
|
||||
but for string, assign fun just copy the pointer, so in device manager, should manager
|
||||
but for string, assign fun just copy the pointer, so in device manager, should manager
|
||||
key mem space, in case upper lever release the pointer.
|
||||
*/
|
||||
typedef common::hash::ObHashMap<ObString, ObDeviceInsInfo*> StoragInfoDeviceInfoMap;
|
||||
typedef common::hash::ObHashMap<int64_t, ObDeviceInsInfo*> DeviceHandleDeviceInfoMap;
|
||||
|
||||
int alloc_device(ObDeviceInsInfo*& device_info,
|
||||
int alloc_device(ObDeviceInsInfo*& device_info,
|
||||
const common::ObString& storage_info,
|
||||
const common::ObString& storage_type_prefix);
|
||||
|
||||
|
||||
common::ObFIFOAllocator allocator_; /*alloc/free dynamic device mem*/
|
||||
int32_t device_count_;
|
||||
common::ObSpinLock lock_; /*the manager is global used, so need lock to guarante thread safe*/
|
||||
|
||||
Reference in New Issue
Block a user