diff options
| author | Chris Lu <chris.lu@gmail.com> | 2012-11-13 12:13:40 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2012-11-13 12:13:40 -0800 |
| commit | 9782ace1bdcf055da8ae22f39e7aff975d878de4 (patch) | |
| tree | aba09623d1c7999a01561763c9b5ab83273d9576 /weed-fs | |
| parent | 6f606bb35072160b4e030e41d0cf4bb5113e9242 (diff) | |
| download | seaweedfs-9782ace1bdcf055da8ae22f39e7aff975d878de4.tar.xz seaweedfs-9782ace1bdcf055da8ae22f39e7aff975d878de4.zip | |
add locking when adjusting topology
Diffstat (limited to 'weed-fs')
| -rw-r--r-- | weed-fs/src/pkg/replication/volume_growth.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/weed-fs/src/pkg/replication/volume_growth.go b/weed-fs/src/pkg/replication/volume_growth.go index 3942c5743..b73a89339 100644 --- a/weed-fs/src/pkg/replication/volume_growth.go +++ b/weed-fs/src/pkg/replication/volume_growth.go @@ -7,6 +7,7 @@ import ( "pkg/operation" "pkg/storage" "pkg/topology" + "sync" ) /* @@ -22,6 +23,8 @@ type VolumeGrowth struct { copy2factor int copy3factor int copyAll int + + accessLock sync.Mutex } func NewDefaultVolumeGrowth() *VolumeGrowth { @@ -46,6 +49,9 @@ func (vg *VolumeGrowth) GrowByType(repType storage.ReplicationType, topo *topolo return 0, errors.New("Unknown Replication Type!") } func (vg *VolumeGrowth) GrowByCountAndType(count int, repType storage.ReplicationType, topo *topology.Topology) (counter int, err error) { + vg.accessLock.Lock() + defer vg.accessLock.Unlock() + counter = 0 switch repType { case storage.Copy000: |
