Revision c9370421

View differences:

input.c
25 25
  uint64_t first_ts;
26 26
};
27 27

  
28
struct input_desc *input_open(const char *fname, uint16_t flags)
28
struct input_desc *input_open(const char *fname, uint16_t flags, int *fds, int fds_size)
29 29
{
30 30
  struct input_desc *res;
31 31
  struct timeval tv;
32 32

  
33
  if (fds_size >= 1) {
34
    *fds = -1; //This input module needs no fds to monitor
35
  }
36

  
33 37
  res = malloc(sizeof(struct input_desc));
34 38
  if (res == NULL) {
35 39
    return NULL;
input.h
11 11

  
12 12
struct input_desc;
13 13

  
14
struct input_desc *input_open(const char *fname, uint16_t flags);
14
struct input_desc *input_open(const char *fname, uint16_t flags, int *fds, int fds_size);
15 15
void input_close(struct input_desc *s);
16 16
int input_get(struct input_desc *s, struct chunk *c);
17 17

  
loop.c
24 24
#include "dbg.h"
25 25

  
26 26
#define BUFFSIZE 512 * 1024
27
#define FDSSIZE 16
27 28
static struct timeval period = {0, 500000};
28 29
static struct timeval tnext;
29 30

  
......
113 114
  int done = 0;
114 115
  static uint8_t buff[BUFFSIZE];
115 116
  int cnt = 0;
117
  int fds[FDSSIZE];
118
  fds[0] = -1;
116 119

  
117 120
  period.tv_sec = csize  / 1000000;
118 121
  period.tv_usec = csize % 1000000;
119 122
  
120 123
  peers_init();
121
  if (source_init(fname, s, loop) < 0) {
124

  
125
  if (source_init(fname, s, loop, fds, FDSSIZE) < 0) {
122 126
    fprintf(stderr,"Cannot initialize source, exiting");
123 127
    return;
124 128
  }
streaming.c
88 88
  init_measures();
89 89
}
90 90

  
91
int source_init(const char *fname, struct nodeID *myID, bool loop)
91
int source_init(const char *fname, struct nodeID *myID, bool loop, int *fds, int fds_size)
92 92
{
93
  input = input_open(fname, loop ? INPUT_LOOP : 0);
93
  input = input_open(fname, loop ? INPUT_LOOP : 0, fds, fds_size);
94 94
  if (input == NULL) {
95 95
    return -1;
96 96
  }
streaming.h
10 10
#include <stdbool.h>
11 11

  
12 12
void stream_init(int size, struct nodeID *myID);
13
int source_init(const char *fname, struct nodeID *myID, bool loop);
13
int source_init(const char *fname, struct nodeID *myID, bool loop, int *fds, int fds_size);
14 14
void received_chunk(struct nodeID *from, const uint8_t *buff, int len);
15 15
void send_chunk();
16 16
struct chunk *generated_chunk(suseconds_t *delta);

Also available in: Unified diff