Changeset 367 for trunk/src/sh_unix.c


Ignore:
Timestamp:
Oct 30, 2011, 9:18:31 AM (13 years ago)
Author:
katerina
Message:

Modifications for ticket #265 (inotify support). Needs testing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_unix.c

    r362 r367  
    35853585#endif   
    35863586
     3587
     3588static void * sh_dummy_filename;
     3589static void * sh_dummy_tmp;
     3590static void * sh_dummy_tmp2;
     3591
    35873592int sh_unix_getinfo (int level, char * filename, file_type * theFile,
    35883593                     char * fileHash, int policy)
     
    35933598  struct stat   lbuf;
    35943599  struct stat   fbuf;
    3595   int           stat_return;
    3596   int           stat_errno = 0;
     3600  volatile int  stat_return;
     3601  volatile int  stat_errno = 0;
    35973602
    35983603  ShFileType    type;
     
    36023607
    36033608  char        * linknamebuf;
    3604   int           linksize;
     3609  volatile int  linksize;
    36053610
    36063611  extern int get_the_fd (SL_TICKET ticket);
    36073612
    3608   SL_TICKET     rval_open;
    3609   int           err_open = 0;
    3610 
    3611   int           fd;
    3612   int           fstat_return;
    3613   int           fstat_errno = 0;
    3614   int           try         = 0;
     3613  volatile SL_TICKET     rval_open;
     3614  volatile int           err_open = 0;
     3615
     3616  volatile int           fd;
     3617  volatile int           fstat_return;
     3618  volatile int           fstat_errno = 0;
     3619  volatile int           try         = 0;
    36153620
    36163621  sh_string   * content = NULL;
     
    36223627  char * path = NULL;
    36233628
    3624   int alert_timeout   = 120;
     3629  volatile int alert_timeout   = 120;
    36253630
    36263631  path = theFile->fullpath;
    36273632
    36283633  SL_ENTER(_("sh_unix_getinfo"));
     3634
     3635  /* Take the address to keep gcc from putting it into a register.
     3636   * Avoids the 'clobbered by longjmp' warning.
     3637   */
     3638  sh_dummy_filename = (void *) &filename;
     3639  sh_dummy_tmp      = (void *) &tmp;
     3640  sh_dummy_tmp2     = (void *) &tmp2;
    36293641
    36303642  /* --- Stat the file, and get checksum. ---
     
    36563668          if (stale)
    36573669            {
     3670              SH_MUTEX_LOCK(mutex_thread_nolog);
    36583671              sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, err_open, MSG_E_SUBGEN,
    36593672                              stale, _("sh_unix_getinfo_open"));
     3673              SH_MUTEX_UNLOCK(mutex_thread_nolog);
    36603674            }
    36613675
     
    36883702    {
    36893703      tmp2 = sh_util_safe_name (theFile->fullpath);
     3704      SH_MUTEX_LOCK(mutex_thread_nolog);
    36903705      sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_TOOLATE,
    36913706                       (long)(tend - tstart), tmp2);
     3707      SH_MUTEX_UNLOCK(mutex_thread_nolog);
    36923708      SH_FREE(tmp2);
    36933709    }
     
    37073723          if (stale)
    37083724            {
     3725              SH_MUTEX_LOCK(mutex_thread_nolog);
    37093726              sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, fstat_errno,
    37103727                              MSG_E_SUBGEN,
    37113728                              stale, _("sh_unix_getinfo_fstat"));
     3729              SH_MUTEX_UNLOCK(mutex_thread_nolog);
    37123730            }
    37133731
     
    37423760            (void) sl_get_euid(&euid);
    37433761            tmp2 = sh_util_safe_name (theFile->fullpath);
     3762            SH_MUTEX_LOCK(mutex_thread_nolog);
    37443763            sh_error_handle (level, FIL__, __LINE__, stat_return, MSG_FI_STAT,
    37453764                             _("lstat"),
     
    37473766                             (long) euid,
    37483767                             tmp2);
     3768            SH_MUTEX_UNLOCK(mutex_thread_nolog);
    37493769            SH_FREE(tmp2);
    37503770          }
     
    38943914              (void) sl_get_euid(&euid);
    38953915
     3916              SH_MUTEX_LOCK(mutex_thread_nolog);
    38963917              sh_error_handle (level, FIL__, __LINE__, stat_return, MSG_FI_STAT,
    38973918                               _("fstat"),
     
    38993920                               (long) euid,
    39003921                               tmp2);
     3922              SH_MUTEX_UNLOCK(mutex_thread_nolog);
    39013923            }
    39023924          else if (fd >= 0 && !S_ISREG(fbuf.st_mode))
    39033925            {
     3926              SH_MUTEX_LOCK(mutex_thread_nolog);
    39043927              sh_error_handle (level, FIL__, __LINE__, fstat_errno,
    39053928                               MSG_E_NOTREG, tmp2);
     3929              SH_MUTEX_UNLOCK(mutex_thread_nolog);
    39063930            }
    39073931          else
     
    39113935              sl_strlcpy(errbuf, sl_error_string(rval_open), sizeof(errbuf));
    39123936              sh_error_message(err_open, errbuf2, sizeof(errbuf2));
     3937              SH_MUTEX_LOCK(mutex_thread_nolog);
    39133938              sh_error_handle (level, FIL__, __LINE__, err_open,
    39143939                               MSG_E_READ, errbuf, errbuf2, tmp2);
     3940              SH_MUTEX_UNLOCK(mutex_thread_nolog);
    39153941            }
    39163942          SH_FREE(tmp2);
     
    40044030    if (policy == SH_LEVEL_ALLIGNORE)
    40054031      {
     4032        SH_MUTEX_LOCK(mutex_thread_nolog);
    40064033        sh_error_handle (SH_ERR_ALL, FIL__, __LINE__, ENOENT,
    40074034                         MSG_FI_NOGRP,
    40084035                         (long) buf.st_gid, tmp2);
     4036        SH_MUTEX_UNLOCK(mutex_thread_nolog);
    40094037      }
    40104038    else
    40114039      {
     4040        SH_MUTEX_LOCK(mutex_thread_nolog);
    40124041        sh_error_handle (ShDFLevel[SH_ERR_T_NAME], FIL__, __LINE__, ENOENT,
    40134042                         MSG_FI_NOGRP,
    40144043                         (long) buf.st_gid, tmp2);
     4044        SH_MUTEX_UNLOCK(mutex_thread_nolog);
    40154045      }
    40164046    SH_FREE(tmp2);
     
    40254055    if (policy == SH_LEVEL_ALLIGNORE)
    40264056      {
     4057        SH_MUTEX_LOCK(mutex_thread_nolog);
    40274058        sh_error_handle (SH_ERR_ALL, FIL__, __LINE__, ENOENT,
    40284059                         MSG_FI_NOUSR,
    40294060                         (long) buf.st_uid, tmp2);
     4061        SH_MUTEX_UNLOCK(mutex_thread_nolog);
    40304062      }
    40314063    else
    40324064      {
     4065        SH_MUTEX_LOCK(mutex_thread_nolog);
    40334066        sh_error_handle (ShDFLevel[SH_ERR_T_NAME], FIL__, __LINE__, ENOENT,
    40344067                         MSG_FI_NOUSR,
    40354068                         (long) buf.st_uid, tmp2);
     4069        SH_MUTEX_UNLOCK(mutex_thread_nolog);
    40364070      }
    40374071    SH_FREE(tmp2);
     
    40464080                                theFile->fullpath : filename);
    40474081      (void) sh_unix_time(theFile->mtime, timestr, sizeof(timestr));
     4082      SH_MUTEX_LOCK(mutex_thread_nolog);
    40484083      sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_LIST,
    40494084                       theFile->c_mode,
     
    40544089                       timestr,
    40554090                       tmp2);
     4091      SH_MUTEX_UNLOCK(mutex_thread_nolog);
    40564092      SH_FREE(tmp2);
    40574093    }
     
    40764112          linksize = errno;
    40774113          tmp2 = sh_util_safe_name (theFile->fullpath);
     4114          SH_MUTEX_LOCK(mutex_thread_nolog);
    40784115          sh_error_handle (level, FIL__, __LINE__, linksize, MSG_FI_RDLNK,
    40794116                           sh_error_message (linksize, errbuf, sizeof(errbuf)), tmp2);
     4117          SH_MUTEX_UNLOCK(mutex_thread_nolog);
    40804118          SH_FREE(tmp2);
    40814119          SH_FREE(linknamebuf);
     
    41304168
    41314169              (void) sl_get_euid(&euid);
     4170              SH_MUTEX_LOCK(mutex_thread_nolog);
    41324171              sh_error_handle (level, FIL__, __LINE__, stat_return,
    41334172                               MSG_FI_STAT,
     
    41364175                               (long) euid,
    41374176                               tmp2);
     4177              SH_MUTEX_UNLOCK(mutex_thread_nolog);
    41384178            }
    41394179          else
     
    41414181              /* a dangling link -- everybody seems to have plenty of them
    41424182               */
     4183              SH_MUTEX_LOCK(mutex_thread_nolog);
    41434184              sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_DLNK,
    41444185                               tmp, tmp2);
     4186              SH_MUTEX_UNLOCK(mutex_thread_nolog);
    41454187            }
    41464188          theFile->linkisok = BAD;
     
    41754217        {
    41764218          tmp2 = sh_util_safe_name (linknamebuf);     
     4219          SH_MUTEX_LOCK(mutex_thread_nolog);
    41774220          sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_LLNK,
    41784221                           theFile->link_c_mode, tmp2);
     4222          SH_MUTEX_UNLOCK(mutex_thread_nolog);
    41794223          SH_FREE(tmp2);
    41804224        }
     
    42134257                                _("compressed file too large (%lu bytes)"),
    42144258                                clen);
     4259                    SH_MUTEX_LOCK(mutex_thread_nolog);
    42154260                    sh_error_handle (SH_ERR_WARN, FIL__, __LINE__, -1,
    42164261                                     MSG_E_SUBGPATH, tmsg,
    42174262                                     _("sh_unix_getinfo"), tpath);
     4263                    SH_MUTEX_UNLOCK(mutex_thread_nolog);
    42184264                    SH_FREE(tpath);
    42194265                  }
Note: See TracChangeset for help on using the changeset viewer.