]> diplodocus.org Git - nmh/commitdiff
Don't ignore return value of lkfopendata(), most notably of
authorDavid Levine <levinedl@acm.org>
Sun, 6 Apr 2014 16:12:14 +0000 (11:12 -0500)
committerDavid Levine <levinedl@acm.org>
Sun, 6 Apr 2014 16:12:14 +0000 (11:12 -0500)
seq_read() in folder_read().  Increased LOCK_RETRIES from 5 to 60.

h/prototypes.h
sbr/folder_read.c
sbr/lock_file.c
sbr/seq_read.c
uip/new.c

index f8adbac..4f1d329 100644 (file)
@@ -280,8 +280,12 @@ void seq_printall (struct msgs *);
  *               and a pointer to the filehandle will be stored in
  *               folder structure, where it will later be used by
  *               seq_save().
+ *
+ * Return values:
+ *     OK       - successfully read the sequence files, or they don't exist
+ *     NOTOK    - failed to lock sequence file
  */
-void seq_read (struct msgs * mp, int lockflag);
+int seq_read (struct msgs * mp, int lockflag);
 void seq_save (struct msgs *);
 void seq_setcur (struct msgs *, int);
 void seq_setprev (struct msgs *);
index 5c52abd..73ffe43 100644 (file)
@@ -165,7 +165,15 @@ folder_read (char *name, int lockflag)
     /*
      * Read and initialize the sequence information.
      */
-    seq_read (mp, lockflag);
+    if (seq_read (mp, lockflag) == NOTOK) {
+        char seqfile[PATH_MAX];
+
+        /* Failed to lock sequence file. */
+        snprintf (seqfile, sizeof(seqfile), "%s/%s", mp->foldpath, mh_seq);
+        advise (seqfile, "failed to lock");
+
+        return NULL;
+    }
 
     return mp;
 }
index 1a562f9..3e322ba 100644 (file)
@@ -48,7 +48,7 @@ struct lockinfo {
 /*
  * Number of tries to retry locking
  */
-#define LOCK_RETRIES 5
+#define LOCK_RETRIES 60
 
 /*
  * Amount of time to wait before
index aeb76fc..44e2579 100644 (file)
@@ -15,7 +15,7 @@
  * static prototypes
  */
 static int seq_init (struct msgs *, char *, char *);
-static void seq_public (struct msgs *, int);
+static int seq_public (struct msgs *, int);
 static void seq_private (struct msgs *);
 
 
@@ -25,7 +25,7 @@ static void seq_private (struct msgs *);
  * or context file (for private sequences).
  */
 
-void
+int
 seq_read (struct msgs *mp, int lockflag)
 {
     /*
@@ -37,13 +37,20 @@ seq_read (struct msgs *mp, int lockflag)
 
     /* If folder is empty, don't scan for sequence information */
     if (mp->nummsg == 0)
-       return;
+       return OK;
 
     /* Initialize the public sequences */
-    seq_public (mp, lockflag);
+    if (seq_public (mp, lockflag) == NOTOK) {
+       if (errno == EACCES  ||  errno == EAGAIN  ||  errno == EWOULDBLOCK) {
+           /* Failed to lock sequence file. */
+           return NOTOK;
+        }
+    }
 
     /* Initialize the private sequences */
     seq_private (mp);
+
+    return OK;
 }
 
 
@@ -51,7 +58,7 @@ seq_read (struct msgs *mp, int lockflag)
  * read folder's sequences file for public sequences
  */
 
-static void
+static int
 seq_public (struct msgs *mp, int lockflag)
 {
     int state;
@@ -66,13 +73,13 @@ seq_public (struct msgs *mp, int lockflag)
      * then just return, and do not initialize any public sequences.
      */
     if (mh_seq == NULL || *mh_seq == '\0')
-       return;
+       return OK;
 
     /* get filename of sequence file */
     snprintf (seqfile, sizeof(seqfile), "%s/%s", mp->foldpath, mh_seq);
 
     if ((fp = lkfopendata (seqfile, lockflag ? "r+" : "r")) == NULL)
-       return;
+       return NOTOK;
 
     /* Use m_getfld to scan sequence file */
     for (;;) {
@@ -116,6 +123,8 @@ seq_public (struct msgs *mp, int lockflag)
     } else {
        lkfclosedata (fp, seqfile);
     }
+
+    return OK;
 }
 
 
index 6f99825..a0683dd 100644 (file)
--- a/uip/new.c
+++ b/uip/new.c
@@ -114,7 +114,13 @@ get_msgnums(char *folder, char *sequences[])
 
     if ((fp = lkfopendata (seqfile, "r")) == NULL) {
        free(seqfile);
-       return NULL;
+
+       if (errno == EACCES  ||  errno == EAGAIN  ||  errno == EWOULDBLOCK) {
+           /* Failed to lock sequence file. */
+           adios (seqfile, "failed to lock");
+       } else {
+           return NULL;
+       }
     }
 
     /* Use m_getfld to scan sequence file */