Remove bugs

This commit is contained in:
Quentin 2019-05-14 11:25:33 +02:00
parent 36a6dbaad2
commit 46f54fd145

View file

@ -20,7 +20,6 @@ enum FD_STATE read_packet_from_tcp(int fd, struct buffer_packet* bp) {
if (nread == -1) return FDS_ERR;
bp->aread += nread;
}
printf("read packet size = %d, read on network = %d, computed size to read = %ld.\n", bp->ip.ap.fmt.headers.size, bp->aread, pkt_size_size);
while (bp->aread < bp->ip.ap.fmt.headers.size) {
nread = read(fd, &(bp->ip.ap.raw) + bp->aread, bp->ip.ap.fmt.headers.size - bp->aread);
@ -41,14 +40,12 @@ enum FD_STATE write_packet_to_tcp(int fd, struct buffer_packet* bp) {
ssize_t nwrite;
if (bp->mode != BP_WRITING) return FDS_ERR;
printf("Already written: %d\n", bp->awrite);
while (bp->awrite < get_full_size(bp)) {
nwrite = send(fd, &(bp->ip.ap.raw) + bp->awrite, get_full_size(bp) - bp->awrite, 0);
if (nwrite == -1 && errno == EAGAIN) return FDS_AGAIN;
if (nwrite == -1) return FDS_ERR;
bp->awrite += nwrite;
}
printf("headers.size=%d, fullsize=%ld, bp->awrite=%d, first_read=%d\n", bp->ip.ap.fmt.headers.size, get_full_size (bp), bp->awrite, *(uint16_t*)&(bp->ip.ap.raw));
bp->mode = BP_READING;
bp->aread = 0;
bp->ap_count = 0;