Fix udp again

This commit is contained in:
Quentin Dufour 2019-02-19 14:54:42 +01:00
parent e346230c60
commit a4c3018c79

View file

@ -48,6 +48,12 @@ enum FD_STATE write_packet_to_udp(int fd, struct buffer_packet* bp, struct udp_t
ssize_t nwrite;
size_t bytes_to_send;
size_t pkt_header_size = sizeof(bp->ip.ap.str) - sizeof(char);
struct sockaddr* addr = NULL;
socklen_t addrlen = 0;
if (udp_t->set) {
addr = (struct sockaddr*) &udp_t->addr;
addrlen = sizeof(struct sockaddr_in);
}
if (bp->mode != BP_WRITING) return FDS_ERR;
@ -56,8 +62,8 @@ enum FD_STATE write_packet_to_udp(int fd, struct buffer_packet* bp, struct udp_t
&(bp->ip.ap.str.payload),
bytes_to_send,
0,
(struct sockaddr*)&udp_t->addr,
udp_t->addrlen);
addr,
addrlen);
if (nwrite == -1 && errno == EAGAIN) return FDS_AGAIN;
if (nwrite != bytes_to_send) return FDS_ERR;