Merge branch 'master' of github.com:ennorehling/eressea

This commit is contained in:
Enno Rehling 2016-08-31 17:05:02 +02:00
commit 149a99caa3
2 changed files with 18 additions and 10 deletions

View File

@ -141,7 +141,7 @@
},
"glacier": {
"size": 100,
"herbs": [ "h15", "h16", "h17" ],
"herbs": [ "h18", "h19", "h20" ],
"seed": 2,
"road": 250,
"flags": [ "arctic", "land", "walk", "sail", "fly" ],

View File

@ -102,21 +102,29 @@ void log_rotate(const char *filename, int maxindex)
assert(strlen(filename) < sizeof(buffer[0]) - 4);
sprintf(buffer[dst], "%s.%d", filename, maxindex);
#ifdef HAVE_UNISTD_H
/* make sure we don't overwrite an existing file (hard links) */
unlink(buffer[dst]);
#endif
if (remove(buffer[dst]) != 0) {
if (errno != ENOENT) {
fprintf(stderr, "log rotate %s: %d %s", buffer[dst], errno, strerror(errno));
}
errno = 0;
}
while (maxindex > 0) {
int err, src = 1 - dst;
int src = 1 - dst;
sprintf(buffer[src], "%s.%d", filename, --maxindex);
err = rename(buffer[src], buffer[dst]);
if (err != 0) {
log_debug("log rotate %s: %s", buffer[dst], strerror(errno));
if (rename(buffer[src], buffer[dst]) != 0) {
if (errno != ENOENT) {
fprintf(stderr, "log rotate %s: %d %s", buffer[dst], errno, strerror(errno));
}
errno = 0;
}
dst = src;
}
if (rename(filename, buffer[dst]) != 0) {
log_debug("log rotate %s: %s", buffer[dst], strerror(errno));
if (errno != ENOENT) {
fprintf(stderr, "log rotate %s: %d %s", buffer[dst], errno, strerror(errno));
}
errno = 0;
}
}