Browse Source

Added hearbeat ticker stop to close setup

Toby Chui 2 years ago
parent
commit
56ced27e29
1 changed files with 13 additions and 8 deletions
  1. 13 8
      storage.go

+ 13 - 8
storage.go

@@ -24,7 +24,8 @@ var (
 	baseStoragePool *storage.StoragePool //base storage pool, all user can access these virtual roots
 	//fsHandlers      []*fs.FileSystemHandler //All File system handlers. All opened handles must be registered in here
 	//storagePools    []*storage.StoragePool  //All Storage pool opened
-	bridgeManager *bridge.Record //Manager to handle bridged FSH
+	bridgeManager              *bridge.Record //Manager to handle bridged FSH
+	storageHeartbeatTickerChan chan bool      //Channel to stop the storage heartbeat ticker
 )
 
 func StorageInit() {
@@ -118,7 +119,7 @@ func LoadBaseStoragePool() error {
 	return nil
 }
 
-//Initialize the storage connection health check for all fsh.
+// Initialize the storage connection health check for all fsh.
 func storageHeartbeatTickerInit() {
 	ticker := time.NewTicker(60 * time.Second)
 	done := make(chan bool)
@@ -132,11 +133,11 @@ func storageHeartbeatTickerInit() {
 			}
 		}
 	}()
-
+	storageHeartbeatTickerChan = done
 }
 
-//Perform heartbeat to all connected file system abstraction.
-//Blocking function, use with go routine if needed
+// Perform heartbeat to all connected file system abstraction.
+// Blocking function, use with go routine if needed
 func StoragePerformFileSystemAbstractionConnectionHeartbeat() {
 	allFsh := GetAllLoadedFsh()
 	for _, thisFsh := range allFsh {
@@ -179,7 +180,7 @@ func StoragePerformFileSystemAbstractionConnectionHeartbeat() {
 	}
 }
 
-//Initialize group storage pool
+// Initialize group storage pool
 func GroupStoragePoolInit() {
 	//Mount permission groups
 	for _, pg := range permissionHandler.PermissionGroups {
@@ -246,7 +247,7 @@ func LoadStoragePoolForGroup(pg *permission.PermissionGroup) error {
 	return nil
 }
 
-//Check if a storage pool exists by its group owner name
+// Check if a storage pool exists by its group owner name
 func StoragePoolExists(poolOwner string) bool {
 	_, err := GetStoragePoolByOwner(poolOwner)
 	return err == nil
@@ -347,7 +348,7 @@ func RegisterStorageSettings() {
 
 }
 
-//CloseAllStorages Close all storage database
+// CloseAllStorages Close all storage database
 func CloseAllStorages() {
 	allFsh := GetAllLoadedFsh()
 	for _, fsh := range allFsh {
@@ -356,6 +357,10 @@ func CloseAllStorages() {
 }
 
 func closeAllStoragePools() {
+	//Stop the storage pool heartbeat
+	storageHeartbeatTickerChan <- true
+
+	//Close all storage pools
 	for _, sp := range GetAllStoragePools() {
 		sp.Close()
 	}