feedbackReceiver.c 938 Bytes
Newer Older
1
2
#include <string.h>
#include <unistd.h>
3
#include "../../defines.h"
4
5
#include "../../util/common.h"
#include "../../util/dbg.h"
6
#include "../clock.h"
7
8
#include "../packet.h"
#include "../socket.h"
Andreas Schmidt's avatar
Andreas Schmidt committed
9
#include "feedbackReceiver.h"
10

11
void * receive_feedback_loop(void *ptr) {
12
    PrrtSocket *sock_ptr = ptr;
13

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

    return NULL;
27
28
29
30

    error:
        PERROR("Feedback reception failed.");
        return NULL;
31
}