Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-devel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
143
Issues
143
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
emulab
emulab-devel
Commits
42d6c4b8
Commit
42d6c4b8
authored
Aug 14, 2002
by
Robert Ricci
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change locking in exports_setup in the same way I changed it in
named_setup.
parent
e25f9359
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
8 deletions
+49
-8
tbsetup/exports_setup.in
tbsetup/exports_setup.in
+49
-8
No files found.
tbsetup/exports_setup.in
View file @
42d6c4b8
...
...
@@ -78,15 +78,56 @@ use libtestbed;
if
(
!
$TESTMODE
)
{
open
(
LOCK
,
"
>>
$lockfile
")
||
fatal
("
Couldn't open
$lockfile
\n
");
$count
=
0
;
while
(
flock
(
LOCK
,
LOCK_EX
|
LOCK_NB
)
==
0
)
{
print
"
Another /etc/exports update in progress. Waiting a moment ...
\n
";
if
(
flock
(
LOCK
,
LOCK_EX
|
LOCK_NB
)
==
0
)
{
#
# If we don't get it the first time, we wait for:
# 1) The lock to become free, in which case we do our thing
# 2) The time on the lock to change, in which case we wait for that process
# to finish
#
my
$oldlocktime
=
(
stat
(
LOCK
))[
9
];
my
$gotlock
=
0
;
while
(
1
)
{
print
"
Another exports update in progress, waiting for it to finish
\n
";
if
(
flock
(
LOCK
,
LOCK_EX
|
LOCK_NB
)
!=
0
)
{
# OK, got the lock, we can do what we're supposed to
$gotlock
=
1
;
last
;
}
$locktime
=
(
stat
(
LOCK
))[
9
];
if
(
$locktime
!=
$oldlocktime
)
{
$oldlocktime
=
$locktime
;
last
;
}
if
(
$count
++
>
20
)
{
fatal
("
Could not get the lock after a long time!
\n
");
}
sleep
(
1
);
}
$count
=
0
;
#
# If we didn't get the lock, wait for the processes that did to finish
#
if
(
!
$gotlock
)
{
while
(((
stat
(
LOCK
))[
9
]
!=
$oldlocktime
)
&&
(
flock
(
LOCK
,
LOCK_EX
|
LOCK_NB
)
==
0
))
{
if
(
$count
++
>
20
)
{
fatal
("
Could not get the lock after a long time!
\n
");
}
sleep
(
1
);
}
exit
(
0
);
}
}
}
#
# Perl-style touch(1)
#
my
$now
=
time
;
utime
$now
,
$now
,
$lockfile
;
#
# We stick the new map entries into the tail file. First zero it out.
#
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment