Changeset 305 for trunk/src/sh_hash.c


Ignore:
Timestamp:
Nov 13, 2010, 11:24:24 PM (14 years ago)
Author:
katerina
Message:

Fix for ticker #226 (incorrect handling of missing files when secondary schedule is active).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_hash.c

    r294 r305  
    393393}
    394394
     395struct two_sh_file_t {
     396  sh_file_t * prev;
     397  sh_file_t * this;
     398};
     399
    395400static sh_file_t * hashsearch (const char * s);
     401static int hashsearch_prev (const char * s, struct two_sh_file_t * a, int * index);
    396402
    397403static sh_file_t * tab[TABSIZE];
     
    423429  char hashbuf[KEYBUF_SIZE];
    424430  int  retval;
     431  volatile int flag = 0;
    425432
    426433  /* --------  find the entry for the file ----------------       */
     
    449456  sh_error_handle (level, FIL__, __LINE__, 0,
    450457                   MSG_FI_MISS2, tmp, str);
     458  flag = 1;
    451459  SH_FREE(tmp);
    452460  SH_FREE(str);
     
    458466  ; /* 'label at end of compound statement */
    459467  SH_MUTEX_UNLOCK(mutex_hash);
     468
    460469  return retval;
    461470}
     
    625634
    626635
     636
    627637/*********************************************************************
    628638 *
     
    646656  SL_RET0(_("hash_unvisited"));
    647657}
     658
     659/*********************************************************************
     660 *
     661 * Remove a single file from the database.
     662 *
     663 *********************************************************************/
     664void sh_hash_remove (const char * path)
     665{
     666  struct two_sh_file_t entries;
     667  int index;
     668
     669  SL_ENTER(_("sh_hash_remove"));
     670
     671  SH_MUTEX_LOCK(mutex_hash);
     672
     673  if ((sh.flag.reportonce == S_TRUE && sh.flag.update == S_FALSE) ||
     674      (S_TRUE == sh.flag.update && S_TRUE == sh_util_ask_update(path)))
     675    {
     676      if (0 == hashsearch_prev (path, &entries, &index))
     677        {
     678          sh_file_t * p = entries.this;
     679#ifdef REPLACE_OLD
     680          /* Remove the old entry
     681           */
     682          if (entries.prev == p)
     683            tab[index] = p->next;
     684          else
     685            entries.prev->next = p->next;
     686         
     687          p = delete_db_entry(p);
     688         
     689          goto end;
     690          SL_RET0(_("sh_hash_remove"));
     691#else
     692          SET_SH_FFLAG_REPORTED(p->fflags);
     693#endif
     694        }
     695    }
     696
     697 end:
     698  ; /* 'label at end of compound statement' */
     699  SH_MUTEX_UNLOCK(mutex_hash);
     700
     701  SL_RET0(_("sh_hash_remove"));
     702}
     703
    648704
    649705/*********************************************************************
     
    772828    }
    773829  SL_RETURN( NULL, _("hashsearch"));
     830}
     831
     832static int hashsearch_prev (const char * s, struct two_sh_file_t * a, int * index)
     833{
     834  sh_file_t * this;
     835  sh_file_t * prev = NULL;
     836
     837  SL_ENTER(_("hashsearch_prev"));
     838
     839  if (s)
     840    {
     841      *index = hashfunc(s);
     842
     843      this = tab[*index];
     844
     845      prev  = this;
     846
     847      if (this)
     848        {
     849          do {
     850           
     851            if ((this->fullpath != NULL) && (0 == strcmp(s, this->fullpath)))
     852              {
     853                a->prev = prev;
     854                a->this = this;
     855               
     856                SL_RETURN( 0, _("hashsearch_prev"));
     857              }
     858           
     859            prev = this;
     860            this = this->next;
     861           
     862          } while(this);
     863        }
     864    }
     865  SL_RETURN( -1, _("hashsearch"));
    774866}
    775867
     
    22262318  int i;
    22272319  SL_ENTER(_("sh_hash_set_missing"));
     2320
    22282321  i = sh_hash_set_visited_int(newname, SH_FFLAG_CHECKED);
     2322
     2323  if (sh.flag.checkSum != SH_CHECK_INIT) {
     2324    sh_hash_remove(newname);
     2325  }
     2326
    22292327  SL_RETURN(i, _("sh_hash_set_missing"));
    22302328}
Note: See TracChangeset for help on using the changeset viewer.