Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug#482525: failure to fcntl-lock history file, takes ages to create interactive session



On 2008-05-23 13:24:08 +0000, Clint Adams wrote:
> On Fri, May 23, 2008 at 11:46:36AM +0200, martin f krafft wrote:
> > This repeats a number of times before it finally moves on. Complete
> > strace is attached. Search for "EIO".
> 
> Out of curiosity, does the same thing happen if you use -o nolock on
> the client?

Don't you mean -o nohistfcntllock?

I've attached a small program to test whether fcntl lock is working.

Usage: tfcntl <file> <sleeptime>

It will lock the file <file> for <sleeptime> seconds. You can execute
it with <sleeptime> = 1. If you don't get the prompt after 1 second,
then there's a problem. I've already seen such problems in the past
(the NFS server needed to be rebooted), which affected other software
using fcntl lock, e.g. mail software.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.org/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.org/blog/>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>

int main (int argc, char *argv[])
{
  FILE *f;
  int fd;
  struct flock lck;

  if (argc != 3)
  {
    fprintf (stderr, "Usage: tfcntl <file> <sleeptime>\n");
    exit (1);
  }

  f = fopen (argv[1], "r+b");
  if (f == NULL)
  {
    fprintf (stderr, "tfcntl: can't open file %s\n", argv[1]);
    perror ("tfnctl");
    exit (2);
  }
  fd = fileno (f);

  memset (&lck, 0, sizeof (struct flock));
  lck.l_type = F_WRLCK;
  lck.l_whence = SEEK_SET;
  if (fcntl (fd, F_SETLK, &lck) == -1)
  {
    fprintf (stderr, "tfcntl: lock failed (errno = %d)\n", errno);
    perror ("tfnctl");
    exit (3);
  }

  sleep(atoi(argv[2]));

  memset (&lck, 0, sizeof (struct flock));
  lck.l_type = F_UNLCK;
  lck.l_whence = SEEK_SET;
  fcntl (fd, F_SETLK, &lck);

  return 0;
}


Messages sorted by: Reverse Date, Date, Thread, Author