/*
- * $Id: stat.cc,v 1.40 1996/07/15 23:13:33 wessels Exp $
+ * $Id: stat.cc,v 1.41 1996/07/17 17:03:20 wessels Exp $
*
* DEBUG: section 18 Cache Manager Statistics
* AUTHOR: Harvest Derived
/* log convert end handler */
/* call when a walk is completed or error. */
-void logReadEndHandler(fd_unused, errflag_unused, data)
- int fd_unused;
+void logReadEndHandler(fd, errflag_unused, data)
+ int fd;
int errflag_unused;
log_read_data_t *data;
{
storeAppendPrintf(data->sentry, close_bracket);
storeComplete(data->sentry);
safe_free(data);
+ file_close(fd);
}
StoreEntry *sentry;
{
log_read_data_t *data = NULL;
+ int fd;
if (obj->logfile_status == LOG_DISABLE) {
/* Manufacture status when logging is disabled */
storeComplete(sentry);
return;
}
+ fd = file_open(obj->logfilename, NULL, O_RDONLY);
+ if (fd < 0) {
+ debug(18, 0, "Cannot open logfile: %s: %s\n",
+ obj->logfilename, xstrerror());
+ return;
+ }
data = xcalloc(1, sizeof(log_read_data_t));
data->sentry = sentry;
storeAppendPrintf(sentry, "{\n");
- file_walk(obj->logfile_fd, (FILE_WALK_HD) logReadEndHandler,
- (void *) data, (FILE_WALK_LHD) logReadHandler, (void *) data);
+ file_walk(fd,
+ (FILE_WALK_HD) logReadEndHandler,
+ (void *) data,
+ (FILE_WALK_LHD) logReadHandler,
+ (void *) data);
return;
}
{
static char tmp[6000]; /* MAX_URL is 4096 */
char *buf = NULL;
+ int x;
getCurrentTime();
method,
url,
ident);
- if (file_write(obj->logfile_fd, buf = xstrdup(tmp), strlen(tmp),
- obj->logfile_access, NULL, NULL) != DISK_OK) {
+ x = file_write(obj->logfile_fd,
+ buf = xstrdup(tmp),
+ strlen(tmp),
+ obj->logfile_access,
+ NULL,
+ NULL,
+ xfree);
+ if (x != DISK_OK) {
debug(18, 1, "log_append: File write failed.\n");
safe_free(buf);
}
obj->logfile_status = LOG_ENABLE;
/* open the logfile */
- obj->logfile_fd = file_open(obj->logfilename, NULL, O_RDWR | O_CREAT);
+ obj->logfile_fd = file_open(obj->logfilename, NULL, O_WRONLY | O_CREAT);
if (obj->logfile_fd == DISK_ERROR) {
debug(18, 0, "Cannot open logfile: %s\n", obj->logfilename);
obj->logfile_status = LOG_DISABLE;
unlink(obj->logfilename);
/* reopen it anyway */
- obj->logfile_fd = file_open(obj->logfilename, NULL, O_RDWR | O_CREAT);
+ obj->logfile_fd = file_open(obj->logfilename, NULL, O_WRONLY | O_CREAT);
if (obj->logfile_fd == DISK_ERROR) {
debug(18, 0, "Cannot open logfile: %s\n", obj->logfilename);
obj->logfile_status = LOG_DISABLE;
obj->server_list = server_list;
xmemcpy(obj->logfilename, logfilename, (int) (strlen(logfilename) + 1) % 256);
- obj->logfile_fd = file_open(obj->logfilename, NULL, O_RDWR | O_CREAT);
+ obj->logfile_fd = file_open(obj->logfilename, NULL, O_WRONLY | O_CREAT);
if (obj->logfile_fd == DISK_ERROR) {
debug(18, 0, "%s: %s\n", obj->logfilename, xstrerror());
fatal("Cannot open logfile.");
/* Close and reopen the log. It may have been renamed "manually"
* before HUP'ing us. */
file_close(CacheInfo->logfile_fd);
- CacheInfo->logfile_fd = file_open(fname, NULL, O_RDWR | O_CREAT | O_APPEND);
+ CacheInfo->logfile_fd = file_open(fname, NULL, O_WRONLY | O_CREAT);
if (CacheInfo->logfile_fd == DISK_ERROR) {
debug(18, 0, "stat_rotate_log: Cannot open logfile: %s\n", fname);
CacheInfo->logfile_status = LOG_DISABLE;