aboutsummaryrefslogtreecommitdiff
path: root/login
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1996-12-16 01:40:21 +0000
committerUlrich Drepper <drepper@redhat.com>1996-12-16 01:40:21 +0000
commit860d3729868a749f782f6ad5dae1138cb239c4d3 (patch)
tree3722e55d8a4059529325df0e6c5ffbd168adbd88 /login
parent68dbb3a69e78e24a778c6602c8cc91d715839d08 (diff)
downloadglibc-860d3729868a749f782f6ad5dae1138cb239c4d3.tar
glibc-860d3729868a749f782f6ad5dae1138cb239c4d3.tar.gz
glibc-860d3729868a749f782f6ad5dae1138cb239c4d3.tar.bz2
glibc-860d3729868a749f782f6ad5dae1138cb239c4d3.zip
update from main archive 961215cvs/libc-961216
Mon Dec 16 02:15:42 1996 Ulrich Drepper <drepper@cygnus.com> Make sure tzset() sets always tzname[]. * time/tzfile.c: De-ANSI-declfy. (find_transition): New function. Set tzname according to given time. (__tzread_file): Use find_transition to set tzname. (__tzfile_compute): Use find_transition instead of doing the work self. * time/tzset.c (tzset): Set tzname[] directly only if !__use_tzfile. Sun Dec 15 16:52:34 1996 Ulrich Drepper <drepper@cygnus.com> * login/utmp-file.c (pututline_file): Open file if closed. Reported by Roma Ekzhanov <ekzhanov@paragraph.com>. Use fcntl instead of flock. Sun Dec 15 14:20:51 1996 Ulrich Drepper <drepper@cygnus.com> * manual/time.texi: Update documentation of strftime function.
Diffstat (limited to 'login')
-rw-r--r--login/utmp_file.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/login/utmp_file.c b/login/utmp_file.c
index c728d9a1f2..102eba02e1 100644
--- a/login/utmp_file.c
+++ b/login/utmp_file.c
@@ -140,14 +140,14 @@ getutent_r_file (struct utmp *buffer, struct utmp **result)
memset (&fl, '\0', sizeof (struct flock));
fl.l_type = F_WRLCK;
fl.l_whence = SEEK_SET;
- result = fcntl (file_fd, F_SETLKW, &fl);
+ fcntl (file_fd, F_SETLKW, &fl);
/* Read the next entry. */
nbytes = read (file_fd, &last_entry, sizeof (struct utmp));
/* And unlock the file. */
fl.l_type = F_UNLCK;
- result = fcntl (file_fd, F_SETLKW, &fl);
+ fcntl (file_fd, F_SETLKW, &fl);
if (nbytes != sizeof (struct utmp))
{
@@ -292,6 +292,7 @@ getutid_r_file (const struct utmp *id, struct utmp *buffer,
static struct utmp *
pututline_file (const struct utmp *data)
{
+ struct flock fl; /* Information struct for locking. */
struct utmp buffer;
struct utmp *pbuf;
int found;
@@ -300,6 +301,10 @@ pututline_file (const struct utmp *data)
/* Something went wrong. */
return NULL;
+ if (file_fd == INT_MIN)
+ /* The file is closed. Open it again. */
+ setutent_file (0);
+
/* Find the correct place to insert the data. */
if (file_offset > 0)
found = 0;
@@ -318,14 +323,10 @@ pututline_file (const struct utmp *data)
found = internal_getutid_r (data, &buffer);
/* Try to lock the file. */
- if (flock (file_fd, LOCK_EX | LOCK_NB) < 0 && errno != ENOSYS)
- {
- /* Oh, oh. The file is already locked. Wait a bit and try again. */
- sleep (1);
-
- /* This time we ignore the error. */
- (void) flock (file_fd, LOCK_EX | LOCK_NB);
- }
+ memset (&fl, '\0', sizeof (struct flock));
+ fl.l_type = F_WRLCK;
+ fl.l_whence = SEEK_SET;
+ fcntl (file_fd, F_SETLKW, &fl);
if (found < 0)
{
@@ -338,8 +339,8 @@ pututline_file (const struct utmp *data)
if (lseek (file_fd, 0, SEEK_END) < 0)
{
- (void) flock (file_fd, LOCK_UN);
- return NULL;
+ pbuf = NULL;
+ goto unlock_return;
}
}
}
@@ -365,8 +366,10 @@ pututline_file (const struct utmp *data)
pbuf = (struct utmp *) data;
}
+ unlock_return:
/* And unlock the file. */
- (void) flock (file_fd, LOCK_UN);
+ fl.l_type = F_UNLCK;
+ fcntl (file_fd, F_SETLKW, &fl);
return pbuf;
}