mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
Added configurable setvbuf to output of file node
This commit is contained in:
parent
b975e16747
commit
117913287d
2 changed files with 12 additions and 2 deletions
|
@ -50,6 +50,7 @@ struct file {
|
|||
int flush; /**< Flush / upload file contents after each write. */
|
||||
struct task task; /**< Timer file descriptor. Blocks until 1 / rate seconds are elapsed. */
|
||||
double rate; /**< The read rate. */
|
||||
size_t buffer_size; /**< Defines size of stream buffer. No buffer is created if value is set to zero. */
|
||||
|
||||
enum epoch_mode {
|
||||
FILE_EPOCH_DIRECT,
|
||||
|
|
|
@ -89,8 +89,9 @@ int file_parse(struct node *n, json_t *cfg)
|
|||
f->eof = FILE_EOF_EXIT;
|
||||
f->epoch_mode = FILE_EPOCH_DIRECT;
|
||||
f->flush = 0;
|
||||
f->buffer_size = 0;
|
||||
|
||||
ret = json_unpack_ex(cfg, &err, 0, "{ s: s, s?: s, s?: { s?: s, s?: F, s?: s, s?: F }, s?: { s?: b } }",
|
||||
ret = json_unpack_ex(cfg, &err, 0, "{ s: s, s?: s, s?: { s?: s, s?: F, s?: s, s?: F }, s?: { s?: b, s?: i } }",
|
||||
"uri", &uri_tmpl,
|
||||
"format", &format,
|
||||
"in",
|
||||
|
@ -99,7 +100,8 @@ int file_parse(struct node *n, json_t *cfg)
|
|||
"epoch_mode", &epoch_mode,
|
||||
"epoch", &epoch_flt,
|
||||
"out",
|
||||
"flush", &f->flush
|
||||
"flush", &f->flush,
|
||||
"buffer_size", &f->buffer_size
|
||||
);
|
||||
if (ret)
|
||||
jerror(&err, "Failed to parse configuration of node %s", node_name(n));
|
||||
|
@ -219,6 +221,13 @@ int file_start(struct node *n)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (f->buffer_size) {
|
||||
ret = setvbuf(f->io.output.stream.std, NULL, _IOFBF, f->buffer_size);
|
||||
if(ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* Create timer */
|
||||
ret = task_init(&f->task, f->rate, CLOCK_REALTIME);
|
||||
if (ret)
|
||||
|
|
Loading…
Add table
Reference in a new issue