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
Open sidebar
emacs
emacs
Commits
a1faca26
Commit
a1faca26
authored
Sep 12, 1996
by
Richard M. Stallman
Browse files
(lock_superlock): Delete superlock file if it stayed
locked for 20 seconds.
parent
9614b740
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
11 deletions
+43
-11
src/filelock.c
src/filelock.c
+43
-11
No files found.
src/filelock.c
View file @
a1faca26
...
@@ -353,32 +353,64 @@ lock_superlock (lfname)
...
@@ -353,32 +353,64 @@ lock_superlock (lfname)
{
{
register
int
i
,
fd
;
register
int
i
,
fd
;
DIR
*
lockdir
;
DIR
*
lockdir
;
struct
stat
first_stat
,
last_stat
;
for
(
i
=
-
20
;
i
<
0
&&
(
fd
=
open
(
superlock_file
,
for
(
i
=
-
20
;
i
<
0
;
O_WRONLY
|
O_EXCL
|
O_CREAT
,
0666
))
<
0
;
i
++
)
i
++
)
{
{
fd
=
open
(
superlock_file
,
O_WRONLY
|
O_EXCL
|
O_CREAT
,
0666
);
/* If we succeeded in creating the superlock, we win.
Fill in our info and return. */
if
(
fd
>=
0
)
{
#ifdef USG
chmod
(
superlock_file
,
0666
);
#else
fchmod
(
fd
,
0666
);
#endif
write
(
fd
,
lfname
,
strlen
(
lfname
));
close
(
fd
);
return
;
}
/* If the problem is not just that it is already locked,
give up. */
if
(
errno
!=
EEXIST
)
if
(
errno
!=
EEXIST
)
return
;
return
;
message
(
"Superlock file exists, retrying..."
);
if
(
i
==
-
20
)
stat
(
superlock_file
,
&
first_stat
);
if
(
i
==
-
1
)
stat
(
superlock_file
,
&
last_stat
);
/* This seems to be necessary to prevent Emacs from hanging when the
/* This seems to be necessary to prevent Emacs from hanging when the
competing process has already deleted the superlock, but it's still
competing process has already deleted the superlock, but it's still
in the NFS cache. So we force NFS to synchronize the cache. */
in the NFS cache. So we force NFS to synchronize the cache. */
if
(
lockdir
=
opendir
(
lock_dir
))
lockdir
=
opendir
(
lock_dir
);
if
(
lockdir
)
closedir
(
lockdir
);
closedir
(
lockdir
);
sleep
(
1
);
sleep
(
1
);
}
}
if
(
fd
>=
0
)
if
(
first_stat
.
st_ctime
==
last_stat
.
st_ctime
)
{
{
#ifdef USG
int
value
;
chmod
(
superlock_file
,
0666
);
value
=
unlink
(
superlock_file
);
#else
fchmod
(
fd
,
0666
);
if
(
value
!=
-
1
)
#endif
message
(
"Superlock file deleted"
);
write
(
fd
,
lfname
,
strlen
(
lfname
));
else
close
(
fd
);
message
(
"Failed to delete superlock file"
);
}
}
else
message
(
"Giving up on the superlock file"
);
}
}
void
void
...
...
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