Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37766599
en ru br
ALT Linux repositórios
S:1.2.9a-alt2
5.0: 1.2.7-alt1
4.1: 1.2.6-alt1
4.0: 1.2.5-alt1
3.0: 1.2-alt1

Group :: Sistema/Servidores
RPM: pdnsd

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

Patch: pdnsd-1.2-alt-cache.patch
Download


--- pdnsd-1.2/src/cache.c-	2004-10-13 21:49:04 +0000
+++ pdnsd-1.2/src/cache.c	2004-10-13 21:59:53 +0000
@@ -1027,6 +1027,9 @@ static void purge_cache(long sz, int laz
         log_warn("%s encountered while reading %s from disk cache file.", \
         ferror(f)?"Error":feof(f)?"EOF":"Incomplete item",item)
 
+static FILE *f;
+#define FCLOSE(f) fclose(f),f=NULL
+
 /*
  * Load cache from disk and rebuild the hash tables.
  */
@@ -1037,13 +1040,12 @@ void read_disk_cache()
 	int dtsz=512;
 	unsigned char *data;
 	unsigned long cnt;
-	FILE *f;
 
 	char path[strlen(global.cache_dir)+sizeof("/pdnsd.cache")];
 
 	stpcpy(stpcpy(path,global.cache_dir),"/pdnsd.cache");
 
-	if (!(f=fopen(path,"r"))) {
+	if (!(f=fopen(path,"r+"))) {
 		log_warn("Could not open disk cache file %s: %s",path,strerror(errno));
 		return;
 	}
@@ -1157,7 +1159,6 @@ void read_disk_cache()
 	}
 #ifdef DEBUG_HASH
 	free(data);
-	fclose(f);
 	dumphash();
 	goto sort_return;
 #else
@@ -1168,7 +1169,6 @@ void read_disk_cache()
 	free_cent(&ce  DBG0);
  free_data_fclose:
 	free(data);
-	fclose(f);
 #ifdef DEBUG_HASH
  sort_return:
 #endif
@@ -1189,13 +1189,12 @@ void read_disk_cache()
  free_data_fclose_exit:
 	free(data);
  fclose_exit:
-	fclose(f);
 	log_error("Out of memory in reading cache file. Exiting.");
 	pdnsd_exit();
 }
 
 /* write an rr to the file f */
-static int write_rrset(int tp, rr_set_t *rrs, FILE *f)
+static int write_rrset(int tp, rr_set_t *rrs)
 {
 	rr_bucket_t *rr;
 	rr_fset_t sh;
@@ -1244,7 +1243,6 @@ void write_disk_cache()
 	dns_cent_t *le;
 	unsigned long en=0;
 	dns_hash_pos_t pos;
-	FILE *f;
 	unsigned long num_rrs_errs=0;
 #	define MAX_NUM_RRS_ERRS 10
 
@@ -1267,8 +1265,8 @@ void write_disk_cache()
 		goto lock_failed;
 	}
 
-	if (!(f=fopen(path,"w"))) {
-		log_warn("Could not open disk cache file %s: %s",path,strerror(errno));
+	if (fseek(f,0,SEEK_SET)) {
+		log_warn("Could not write disk cache file %s: %s",path,strerror(errno));
 		goto softunlock_return;
 	}
 
@@ -1341,13 +1339,13 @@ void write_disk_cache()
 			for (j=0;j<T_NUM;j++) {
 				rr_set_t *rrset=le->rr[j];
 				if(rrset && !(rrset->flags&CF_LOCAL)) {
-					if(!write_rrset(j+T_MIN,rrset,f))
+					if(!write_rrset(j+T_MIN,rrset))
 						goto fclose_unlock;
 				}
 			}
 		}
 	}
-	if(fclose(f)) {
+	if(FCLOSE(f)) {
 		log_error("Could not close cache file %s after writing cache: %s", path,strerror(errno));
 	}
 	softunlock_cache_r();
@@ -1355,7 +1353,7 @@ void write_disk_cache()
 	return;
 
  fclose_unlock:
-	fclose(f);
+	FCLOSE(f);
  softunlock_return:
 	softunlock_cache_r();
 	return;
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009