Revision 81b601c1 input-http.c

View differences:

input-http.c
19 19
#include "input.h"
20 20

  
21 21
extern struct chunk_buffer *cb;
22

  
23
#ifdef THREADS
24
extern pthread_mutex_t cb_mutex;
25
extern pthread_mutex_t topology_mutex;
26
#else
22 27
pthread_mutex_t cb_mutex;
28
#endif
23 29

  
24 30
struct input_desc {
25 31
  int dummy;
......
42 48

  
43 49
  res->dummy = 0;
44 50
dprintf("BEFORE INIT! %d\n", res->dummy);
51
#ifndef THREADS
45 52
  pthread_mutex_init(&cb_mutex, NULL);
53
#endif
46 54
  //this daemon will listen the network for incoming chunks from a streaming source
47 55
  //on the following path and port
48 56
  httpd = initChunkPuller(UL_DEFAULT_CHUNKBUFFER_PATH, UL_DEFAULT_CHUNKBUFFER_PORT);
......
86 94
	}
87 95

  
88 96
  if(cb) {
97
#ifdef THREADS
98
  	pthread_mutex_lock(&topology_mutex);
99
#endif
89 100
  	pthread_mutex_lock(&cb_mutex);
90
  	res = cb_add_chunk(cb, gchunk);
91
  	free(gchunk);
92
  	pthread_mutex_unlock(&cb_mutex);
93
  }
94
  if (res < 0) { //chunk sequence is older than previous chunk (SHOULD SEND ANYWAY!!!)
95
    free(gchunk->data);
96
    free(gchunk->attributes);
97
    fprintf(stderr, "Chunk %d of %d bytes FAIL res %d\n", gchunk->id, gchunk->size, res);
98
  }
99
  else {
100
    pthread_mutex_lock(&cb_mutex);
101
    send_chunk(); //push it
101
  	res = add_chunk(gchunk);
102
//  	free(gchunk);
103
//  	pthread_mutex_unlock(&cb_mutex);
104
//  }
105
//  if (res < 0) { //chunk sequence is older than previous chunk (SHOULD SEND ANYWAY!!!)
106
//    free(gchunk->data);
107
//    free(gchunk->attributes);
108
//    fprintf(stderr, "Chunk %d of %d bytes FAIL res %d\n", gchunk->id, gchunk->size, res);
109
//  }
110
//  else {
111
//    pthread_mutex_lock(&cb_mutex);
112
    if(res) send_chunk(); //push it
102 113
    pthread_mutex_unlock(&cb_mutex);
114
#ifdef THREADS
115
  	pthread_mutex_unlock(&topology_mutex);
116
#endif
103 117
  }
104 118

  
105 119
  return 0;

Also available in: Unified diff