mail-cache.c revision 620b5ed41650da63b0ba15c489f9f312231d5d9b
294N/A/* Copyright (c) 2003-2014 Dovecot authors, see the included COPYING file */ 1336N/A /* mark the cache as unusable */ 1336N/A "Corrupted index cache file %s: %s",
789N/A /* we're waiting for compression */ 294N/A /* see if the file has changed */ 911N/A /* if the old file has been deleted, the new file may have 911N/A the same inode as the old one. we'll catch this here by 911N/A checking if fstat() fails with ESTALE */ 1339N/A /* still different - maybe a race condition or maybe the 1339N/A file_seq really is corrupted. either way, this shouldn't 1340N/A happen often so we'll just mark cache to be compressed 869N/A /* reopening does no good */ 1109N/A /* compress to get ourself into the new header version */ 869N/A /* probably not the real record_count, but hole offset that 869N/A Dovecot <=v2.1 versions used to use in this position. 868N/A we already checked that minor_version>0, but this could 870N/A happen if old Dovecot was used to access mailbox after 870N/A it had been updated. */ 1336N/A /* too many continued rows, compress */ 1336N/A /* too many deleted records, compress */ 787N/A /* check that the header is still ok */ 789N/A /* version changed - upgrade silently */ 877N/A /* architecture change - handle silently(?) */ 869N/A /* index id changed - handle silently */ 869N/A /* verify the header validity only with offset=0. this way 294N/A we won't waste time re-verifying it all the time */ 1340N/A /* we can usually read the fields header after the cache 1340N/A header. we need them both, so try to read them all with one 789N/A /* verify offset + size before trying to allocate a huge amount of 789N/A memory due to them. note that we may be prefetching more than we 789N/A actually need, so don't fail too early. */ 1091N/A /* In case of ESTALE we'll simply fail without error 1091N/A messages. The caller will then just have to 1091N/A fallback to generating the value itself. 1091N/A We can't simply reopen the cache flie, because 1091N/A using it requires also having updated file 789N/A /* unusable, waiting for compression or 789N/A /* map the whole file */ 789N/A /* failed for some reason - doesn't really matter, 789N/A it's disabled for now. */ 789N/A /* previous locking failed. don't waste time waiting on it 1339N/A again, just try once to see if it's available now. */ 789N/A "file_dotlock_create()");
789N/A /* don't bother warning if locking failed due to a timeout. since cache 789N/A updating isn't all that important we're using a very short timeout 1339N/A so it can be triggered sometimes on heavy load */ 873N/A for (i = 0; i <
3; i++) {
1086N/A /* we want the latest cache file */ 1086N/A /* either we're still waiting for index to 1339N/A catch up with a cache compression, or 1339N/A that catching up is never going to happen */ 857N/A /* okay, so it was just compressed. try again. */ 1339N/A /* make sure our header is up to date */ 294N/A /* we found it to be broken during the lock. just clean up. */ 789N/A /* FIXME: this is updated only so that older Dovecot versions (<=v2.1) 789N/A can read this file. we can remove this later. */ 787N/A /* all messages are too old */