feedback_receiver.c 770 Bytes
Newer Older
1
2
#include <string.h>
#include <unistd.h>
Andreas Schmidt's avatar
Andreas Schmidt committed
3
4
5
#include <src/defines.h>
#include <src/prrt/packet.h>
#include <src/prrt/socket.h>
6
#include <src/util/dbg.h>
7
8
9
10
11
#include "feedback_receiver.h"

void *receive_feedback_loop(void *ptr) {
    char bufin[MAX_PAYLOAD_LENGTH];

12
    PrrtSocket *sock_ptr = ptr;
13

14
15
16
    pthread_mutex_lock(&sock_ptr->closingMutex);
    while (sock_ptr->closing == FALSE) {
        pthread_mutex_unlock(&sock_ptr->closingMutex);
17
        memset(bufin, 0, MAX_PAYLOAD_LENGTH);
18
        PrrtPacket *t = PrrtSocket_recv_feedback(sock_ptr, bufin, MAX_PAYLOAD_LENGTH);
19
        if (t != NULL) {
20
            PrrtPacket_destroy(t);
21
        }
22
23
        usleep(1);
        pthread_mutex_lock(&sock_ptr->closingMutex);
24
    }
25
    pthread_mutex_unlock(&sock_ptr->closingMutex);
26
}