Changeset ab637c1792a4b0a60d352968204b4b73999f7d99
- Timestamp:
- 05/12/10 15:19:19
(3 years ago)
- Author:
- Mark Harrison <mark@omniti.com>
- git-committer:
- Mark Harrison <mark@omniti.com> 1273677559 +0000
- git-parent:
[98ad146c9d9c3d428099a83049740040d32dc48a]
- git-author:
- Mark Harrison <mark@omniti.com> 1273677559 +0000
- Message:
Add locking when reading/writing resmon state.
git-svn-id: https://labs.omniti.com/resmon/branches/resmon2@368 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r98ad146 |
rab637c1 |
|
| 29 | 29 | my $fh = $self->{shared_state}; |
|---|
| 30 | 30 | if (defined $fh) { |
|---|
| | 31 | flock($fh, LOCK_EX); # Obtain a lock on the file |
|---|
| 31 | 32 | my $VAR1; |
|---|
| 32 | 33 | $fh->seek(0, 0); |
|---|
| … | … | |
| 36 | 37 | $blob = <$fh>; |
|---|
| 37 | 38 | } |
|---|
| | 39 | flock($fh, LOCK_UN); # Release the lock |
|---|
| 38 | 40 | eval $blob; |
|---|
| 39 | 41 | die $@ if ($@); |
|---|
| … | … | |
| 49 | 51 | my $fh = $self->{shared_state}; |
|---|
| 50 | 52 | if (defined($fh)) { |
|---|
| | 53 | flock($fh, LOCK_EX); # Obtain a lock on the file |
|---|
| 51 | 54 | $fh->truncate(0); |
|---|
| 52 | 55 | $fh->seek(0,0); |
|---|
| 53 | 56 | print $fh Dumper($self->{store}); |
|---|
| 54 | 57 | $fh->flush(); |
|---|
| | 58 | flock($fh, LOCK_UN); # Release the lock |
|---|
| 55 | 59 | } else { |
|---|
| 56 | 60 | die "Unable to store shared state"; |
|---|