Revision 53abf41e src/Chunkiser/input-stream-dumb.c

View differences:

src/Chunkiser/input-stream-dumb.c
17 17
#include "config.h"
18 18

  
19 19
struct chunkiser_ctx {
20
  int loop;	//loop on input file infinitely
20 21
  int chunk_size;
21 22
  int fds[2];
22 23
};
......
32 33
    return NULL;
33 34
  }
34 35

  
36
  res->loop = 0;
35 37
  res->fds[0] = open(fname, O_RDONLY);
36 38
  if (res->fds[0] < 0) {
37 39
    free(res);
......
46 48
  if (cfg_tags) {
47 49
    const char *access_mode;
48 50

  
51
    config_value_int(cfg_tags, "loop", &res->loop);
49 52
    config_value_int(cfg_tags, "chunk_size", &res->chunk_size);
50 53
    access_mode = config_value_str(cfg_tags, "mode");
51 54
    if (access_mode && !strcmp(access_mode, "nonblock")) {
......
77 80
  *size = read(s->fds[0], res, s->chunk_size);
78 81
  if ((*size == 0) && (errno != EAGAIN)) {
79 82
    *size = -1;
83
    if (s->loop) {
84
      if (lseek(s->fds[0], 0, SEEK_SET) == 0) {
85
        *size = 0;
86
      }
87
    }
80 88
    free(res);
81 89
    res = NULL;
82 90
  }

Also available in: Unified diff