X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=inn-innduct.git;a=blobdiff_plain;f=backends%2Finnduct.c;h=f0cbf3496c830ad177967cbfb83fa2252359dfb0;hp=2a22ba20a937b0acdd5d845c43e4bc15f3ff66c3;hb=6b1d9ed0da80f22b6ff1c3c678fff5a2ce492fa2;hpb=8c547d5d95d290391bc645a17d195412d20aea9a diff --git a/backends/innduct.c b/backends/innduct.c index 2a22ba2..f0cbf34 100644 --- a/backends/innduct.c +++ b/backends/innduct.c @@ -259,7 +259,6 @@ typedef struct InputFile { void *readable_callback_user; int fd; - const char *path; /* ptr copy of path_ or feedfile */ struct Filemon_Perfile *filemon; oop_read *rd; @@ -267,6 +266,7 @@ typedef struct InputFile { off_t offset; Counts counts; + char path[]; } InputFile; typedef enum { @@ -1113,7 +1113,7 @@ static InputFile *open_input_file(const char *path) { sysfatal("unable to open input file %s", path); } - InputFile *ipf= xmalloc(sizeof(InputFile)); + InputFile *ipf= xmalloc(sizeof(*ipf) + strlen(path) + 1); memset(ipf,0,sizeof(*ipf)); ipf->readable.on_readable= tailing_on_readable; @@ -1121,7 +1121,7 @@ static InputFile *open_input_file(const char *path) { ipf->readable.try_read= tailing_try_read; ipf->fd= fd; - ipf->path= path; + strcpy(ipf->path, path); return ipf; } @@ -1135,8 +1135,6 @@ static void close_input_file(InputFile *ipf) { if (ipf->fd >= 0) if (close(ipf->fd)) sysdie("could not close input file %s", ipf->path); - fixme maybe free ipf->path; - free(ipf); } @@ -1818,7 +1816,7 @@ static int search_backlog_file(void) { debug("backlog scan: found age=%f deficiency=%ld oldest=%s", age, age_deficiency, oldest_path); - backlog_input_file= open_input_file(); + backlog_input_file= open_input_file(oldest_path); if (!backlog_input_file) { warn("backlog file %s vanished as we opened it", backlog_input_file); goto try_again;