mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
pipe: accept partial vectors on stdin
This commit is contained in:
parent
b869729832
commit
52de5f025f
1 changed files with 11 additions and 10 deletions
21
src/pipe.c
21
src/pipe.c
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
static struct super_node sn = { .state = STATE_DESTROYED }; /**< The global configuration */
|
||||
static struct super_node sn = { .state = STATE_DESTROYED }; /**< The global configuration */
|
||||
|
||||
struct dir {
|
||||
struct pool pool;
|
||||
|
@ -103,17 +103,16 @@ static void * send_loop(void *ctx)
|
|||
if (ret < 0)
|
||||
error("Failed to get %u samples out of send pool (%d).", node->vectorize, ret);
|
||||
|
||||
for (;;) {
|
||||
for (int i = 0; i < node->vectorize; i++) {
|
||||
struct sample *s = smps[i];
|
||||
while (!feof(stdin)) {
|
||||
int len;
|
||||
for (len = 0; len < node->vectorize; len++) {
|
||||
struct sample *s = smps[len];
|
||||
int reason;
|
||||
|
||||
retry: reason = sample_io_villas_fscan(stdin, s, NULL);
|
||||
if (reason < 0) {
|
||||
if (feof(stdin)) {
|
||||
info("Reached end-of-file. Terminating...");
|
||||
goto killme;
|
||||
}
|
||||
if (feof(stdin))
|
||||
break;
|
||||
else {
|
||||
warn("Skipped invalid message message: reason=%d", reason);
|
||||
goto retry;
|
||||
|
@ -121,11 +120,13 @@ retry: reason = sample_io_villas_fscan(stdin, s, NULL);
|
|||
}
|
||||
}
|
||||
|
||||
node_write(node, smps, node->vectorize);
|
||||
node_write(node, smps, len);
|
||||
pthread_testcancel();
|
||||
}
|
||||
|
||||
killme: pthread_kill(ptid, SIGINT);
|
||||
/* We reached EOF on stdin here. Lets kill the process */
|
||||
info("Reached end-of-file. Terminating...");
|
||||
pthread_kill(ptid, SIGINT);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue