- while(nsamples >= maxbuffer)
- pthread_cond_wait(&cond, &lock);
- for(pp = &packets;
- *pp && lt((*pp)->timestamp, p->timestamp);
- pp = &(*pp)->next)
- ;
- /* So now either !*pp or *pp >= p */
- if(*pp && p->timestamp == (*pp)->timestamp) {
- /* *pp == p; a duplicate. Ideally we avoid the translation step here,
- * but we'll worry about that another time. */
- info("dropped a duplicated");
- } else {
- if(*pp)
- info("receiving packets out of order");
- p->next = *pp;
- *pp = p;
- nsamples += p->nsamples;
- pthread_cond_broadcast(&cond);
- p = 0; /* we've consumed this packet */
+ if(nsamples >= maxbuffer) {
+ info("buffer full");
+ while(nsamples >= maxbuffer)
+ pthread_cond_wait(&cond, &lock);