Added a function that frees the skygw_file_t memory but doesn't close it.

This commit is contained in:
Markus Makela 2015-04-29 18:25:04 +03:00
parent 9ce225c2cb
commit 47e5b12eb8
3 changed files with 33 additions and 1 deletions

View File

@ -2741,7 +2741,10 @@ static void filewriter_done(
for (i=LOGFILE_FIRST; i<=LOGFILE_LAST; i++)
{
id = (logfile_id_t)i;
skygw_file_close(fw->fwr_file[id], true);
if(use_stdout)
skygw_file_close_stdout(fw->fwr_file[id], true);
else
skygw_file_close(fw->fwr_file[id], true);
}
fw->fwr_state = DONE;
case DONE:

View File

@ -1989,6 +1989,34 @@ return_file:
return file;
}
void skygw_file_close_stdout(
skygw_file_t* file,
bool shutdown)
{
int fd;
int err;
if (file != NULL)
{
CHK_FILE(file);
if (!file_write_footer(file, shutdown))
{
fprintf(stderr,
"* Writing footer to log file %s failed.\n",
file->sf_fname);
perror("Write fike footer\n");
}
fd = fileno(file->sf_file);
fsync(fd);
ss_dfprintf(stderr, "Closed %s\n", file->sf_fname);
free(file->sf_fname);
free(file);
}
}
void skygw_file_close(
skygw_file_t* file,
bool shutdown)

View File

@ -219,6 +219,7 @@ EXTERN_C_BLOCK_END
skygw_file_t* skygw_file_init(char* fname, char* symlinkname);
skygw_file_t* skygw_file_init_stdout(char* fname, char* symlinkname);
void skygw_file_close(skygw_file_t* file, bool shutdown);
void skygw_file_close_stdout(skygw_file_t*, bool);
int skygw_file_write(
skygw_file_t* file,
void* data,