Text   |  XML   |  ReML   |   Visible Warnings:

Negative file descriptor  at nfs-workarounds.c:249

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

mail_cache_lock_full

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-index/mail-cache.c)expand/collapse
Show more  
 541  mail_cache_lock_full(struct mail_cache *cache, bool require_same_reset_id,
 542                       bool nonblock)
 543  {
 544          const struct mail_index_ext *ext;
 545          struct mail_index_view *iview;
 546          uint32_t reset_id;
 547          int i, ret;
 548   
 549          i_assert(!cache->locked);
 550   
 551          if (!cache->opened)
 552[+]                 (void)mail_cache_open_and_verify(cache);
 553   
 554          if (MAIL_CACHE_IS_UNUSABLE(cache) ||
 555              MAIL_INDEX_IS_IN_MEMORY(cache->index))
 556                  return 0;
 557   
 558          iview = mail_index_view_open(cache->index);
 559          ext = mail_index_view_get_ext(iview, cache->ext_id);
 560          reset_id = ext == NULL ? 0 : ext->reset_id;
 561          mail_index_view_close(&iview);
 562   
 563          if (ext == NULL && require_same_reset_id) {
 564                  /* cache not used */
 565                  return 0;
 566          }
 567   
 568          for (i = 0; i < 3; i++) {
 569                  if (cache->hdr->file_seq != reset_id &&
 570                      (require_same_reset_id || i == 0)) {
 571                          /* we want the latest cache file */
 572                          if (reset_id < cache->hdr->file_seq) {
 573                                  /* either we're still waiting for index to 
 574                                     catch up with a cache compression, or 
 575                                     that catching up is never going to happen */
 576                                  ret = 0;
 577                                  break;
 578                          }
 579                          ret = mail_cache_reopen(cache);
 580                          if (ret < 0 || (ret == 0 && require_same_reset_id))
 581                                  break;
 582                  }
 583   
 584[+]                 if ((ret = mail_cache_lock_file(cache, nonblock)) <= 0) {
expand/collapse

mail_cache_lock_file

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-index/mail-cache.c)expand/collapse
Show more  
 490  static int mail_cache_lock_file(struct mail_cache *cache, bool nonblock)
 491  {
 492          int ret;
 493   
 494          if (cache->last_lock_failed) {
 495                  /* previous locking failed. don't waste time waiting on it 
 496                     again, just try once to see if it's available now. */
 497                  nonblock = TRUE;
 498          }
 499   
 500          if (cache->index->lock_method != FILE_LOCK_METHOD_DOTLOCK) {
 501                  i_assert(cache->file_lock == NULL);
 502                  ret = mail_index_lock_fd(cache->index, cache->filepath,
 503                                           cache->fd, F_WRLCK,
 504                                           nonblock ? 0 : MAIL_CACHE_LOCK_TIMEOUT,
 505                                           &cache->file_lock);
 506          } else {
 507                  enum dotlock_create_flags flags =
 508                          nonblock ? DOTLOCK_CREATE_FLAG_NONBLOCK : 0;
 509   
 510                  i_assert(cache->dotlock == NULL);
 511                  ret = file_dotlock_create(&cache->dotlock_settings,
 512                                            cache->filepath, flags,
 513[+]                                           &cache->dotlock);
 514                  if (ret < 0) {
 515                          mail_cache_set_syscall_error(cache,
 516                                                       "file_dotlock_create()");
 517                  }
 518          }
 519          cache->last_lock_failed = ret <= 0;
 520   
 521          /* don't bother warning if locking failed due to a timeout. since cache
 522             updating isn't all that important we're using a very short timeout 
 523             so it can be triggered sometimes on heavy load */
 524          if (ret <= 0)
 525                  return ret;
 526   
 527          mail_index_flush_read_cache(cache->index, cache->filepath, cache->fd,
 528[+]                                     TRUE);
expand/collapse

mail_index_flush_read_cache

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-index/mail-index-lock.c)expand/collapse
Show more  
 123  void mail_index_flush_read_cache(struct mail_index *index, const char *path,
 124                                   int fd, bool locked)
 125  {
 126          if (!index->nfs_flush)
 127                  return;
 128   
 129          /* Assume flock() is emulated with fcntl(), because that's how most
 130             OSes work nowadays. */
 131          if (locked &&
 132              (index->lock_method == FILE_LOCK_METHOD_FCNTL ||
 133               index->lock_method == FILE_LOCK_METHOD_FLOCK)) {
 134                  nfs_flush_read_cache_locked(path, fd);
 135          } else {
 136[+]                 nfs_flush_read_cache_unlocked(path, fd);
expand/collapse

nfs_flush_read_cache_unlocked

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/nfs-workarounds.c)expand/collapse
Show more  
 385  void nfs_flush_read_cache_unlocked(const char *path, int fd)
 386  {
 387  #ifdef READ_CACHE_FLUSH_FCNTL 
 388[+]         if (!nfs_flush_fcntl(path, fd))
expand/collapse

nfs_flush_fcntl

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/nfs-workarounds.c)expand/collapse
Show more  
 217  static bool nfs_flush_fcntl(const char *path, int fd)
 218  {
 219          static bool locks_disabled = FALSE;
 220          struct flock fl;
 221          int ret;
 222   
 223          if (locks_disabled)
 224                  return FALSE;
 225   
 226          /* If the file was already locked, we'll just get the same lock 
 227             again. It should succeed just fine. If was was unlocked, we'll
 228             have to get a lock and then unlock it. Linux 2.6 flushes read cache 
 229             only when read/write locking succeeded. */
 230          fl.l_type = F_RDLCK;
 231          fl.l_whence = SEEK_SET;
 232          fl.l_start = 0;
 233          fl.l_len = 0;
 234   
 235          alarm(60);
 236          ret = fcntl(fd, F_SETLKW, &fl);
 237          alarm(0);
 238   
 239          if (unlikely(ret < 0)) {
 240                  if (errno == ENOLCK) {
 241                          locks_disabled = TRUE;
 242                          return FALSE;
 243                  }
 244                  i_error("nfs_flush_fcntl: fcntl(%s, F_RDLCK) failed: %m", path);
 245                  return FALSE;
 246          }
 247   
 248          fl.l_type = F_UNLCK;
 249          (void)fcntl(fd, F_SETLKW, &fl);
Show more  
Show more  
Show more  
Show more  
Show more  




Change Warning 11478.25534 : Negative file descriptor

Priority:
State:
Finding:
Owner:
Note: