feedback_receiver.c 753 Bytes
Newer Older
1
2
#include <string.h>
#include <unistd.h>
3
4
5
#include "../../defines.h"
#include "../packet.h"
#include "../socket.h"
6
7
#include "feedback_receiver.h"

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

11
    PrrtSocket *sock_ptr = ptr;
12

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

    return NULL;
27
}