Made FDB experiment permanent and bumped to version 0.51.5
This commit is contained in:
@@ -161,11 +161,7 @@ file_list *respfreq(char *nm, char *pw, char *dt)
|
||||
FILE *fa, *fi;
|
||||
long Area;
|
||||
struct FILEIndex idx;
|
||||
#ifdef USE_EXPERIMENT
|
||||
struct _fdbarea *fdb_area = NULL;
|
||||
#else
|
||||
FILE *fb;
|
||||
#endif
|
||||
|
||||
if (localoptions & NOFREQS) {
|
||||
Syslog('+', "File requests disabled");
|
||||
@@ -266,31 +262,12 @@ file_list *respfreq(char *nm, char *pw, char *dt)
|
||||
return NULL;
|
||||
}
|
||||
Syslog('f', "Area %s", area.Name);
|
||||
#ifdef USE_EXPERIMENT
|
||||
if ((fdb_area = mbsedb_OpenFDB(idx.AreaNum, 30)) == 0) {
|
||||
} else {
|
||||
#else
|
||||
p = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(p, "%s/fdb/file%ld.data", getenv("MBSE_ROOT"), idx.AreaNum);
|
||||
if ((fb = fopen(p, "r+")) == NULL) {
|
||||
WriteError("$Can't open %s", p);
|
||||
free(p);
|
||||
} else {
|
||||
free(p);
|
||||
fread(&fdbhdr, sizeof(fdbhdr), 1, fb);
|
||||
#endif
|
||||
if ((fdb_area = mbsedb_OpenFDB(idx.AreaNum, 30))) {
|
||||
|
||||
#ifdef USE_EXPERIMENT
|
||||
if (fseek(fdb_area->fp, fdbhdr.hdrsize + (idx.Record * fdbhdr.recsize), SEEK_SET) == -1) {
|
||||
WriteError("$Can't seek filerecord %d", idx.Record);
|
||||
} else {
|
||||
if (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) != 1) {
|
||||
#else
|
||||
if (fseek(fb, fdbhdr.hdrsize + (idx.Record * fdbhdr.recsize), SEEK_SET) == -1) {
|
||||
WriteError("$Can't seek filerecord %d", idx.Record);
|
||||
} else {
|
||||
if (fread(&fdb, fdbhdr.recsize, 1, fb) != 1) {
|
||||
#endif
|
||||
WriteError("$Can't read filerecord %d", idx.Record);
|
||||
} else {
|
||||
Send = FALSE;
|
||||
@@ -367,25 +344,16 @@ file_list *respfreq(char *nm, char *pw, char *dt)
|
||||
*/
|
||||
fdb.TimesDL++;
|
||||
fdb.LastDL = time(NULL);
|
||||
#ifdef USE_EXPERIMENT
|
||||
if (mbsedb_LockFDB(fdb_area, 30)) {
|
||||
fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
|
||||
fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
|
||||
mbsedb_UnlockFDB(fdb_area);
|
||||
}
|
||||
#else
|
||||
fseek(fb, - fdbhdr.recsize, SEEK_CUR);
|
||||
fwrite(&fdb, fdbhdr.recsize, 1, fb);
|
||||
#endif
|
||||
}
|
||||
free(tnm);
|
||||
}
|
||||
}
|
||||
#ifdef USE_EXPERIMENT
|
||||
mbsedb_CloseFDB(fdb_area);
|
||||
#else
|
||||
fclose(fb);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user