mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
Added separate buffer for input and output section
This commit is contained in:
parent
2a1dc60d16
commit
0c1e92bced
2 changed files with 15 additions and 7 deletions
|
@ -50,7 +50,8 @@ 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. */
|
||||
size_t buffer_size_out; /**< Defines size of output stream buffer. No buffer is created if value is set to zero. */
|
||||
size_t buffer_size_in; /**< Defines size of input stream buffer. No buffer is created if value is set to zero. */
|
||||
|
||||
enum epoch_mode {
|
||||
FILE_EPOCH_DIRECT,
|
||||
|
|
|
@ -89,19 +89,21 @@ 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;
|
||||
f->buffer_size_in = 0;
|
||||
f->buffer_size_out = 0;
|
||||
|
||||
ret = json_unpack_ex(cfg, &err, 0, "{ s: s, s?: s, s?: i, 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?: i }, s?: { s?: b, s?: i } }",
|
||||
"uri", &uri_tmpl,
|
||||
"format", &format,
|
||||
"buffer_size", &f->buffer_size,
|
||||
"in",
|
||||
"eof", &eof,
|
||||
"rate", &f->rate,
|
||||
"epoch_mode", &epoch_mode,
|
||||
"epoch", &epoch_flt,
|
||||
"buffer_size", &f->buffer_size_in,
|
||||
"out",
|
||||
"flush", &f->flush
|
||||
"flush", &f->flush,
|
||||
"buffer_size", &f->buffer_size_out
|
||||
);
|
||||
if (ret)
|
||||
jerror(&err, "Failed to parse configuration of node %s", node_name(n));
|
||||
|
@ -221,12 +223,17 @@ 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 (f->buffer_size_in) {
|
||||
ret = setvbuf(f->io.input.stream.std, NULL, _IOFBF, f->buffer_size_in);
|
||||
if(ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (f->buffer_size_out) {
|
||||
ret = setvbuf(f->io.output.stream.std, NULL, _IOFBF, f->buffer_size_out);
|
||||
if(ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Create timer */
|
||||
ret = task_init(&f->task, f->rate, CLOCK_REALTIME);
|
||||
|
|
Loading…
Add table
Reference in a new issue