Some debug + reset buffers

This commit is contained in:
Quentin 2019-05-24 10:52:49 +02:00
parent 2d0f285bc2
commit 33ba4b2d55
3 changed files with 16 additions and 4 deletions

View file

@ -99,7 +99,7 @@ void rr_deliver(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, struct queue
sprintf(url, "udp:write:127.0.0.1:%d", bp->ip.ap.fmt.content.clear.port);
to_fdinfo = evt_core_get_from_url (ctx, url);
if (to_fdinfo == NULL) {
fprintf(stderr, "No fd for URL %s in udp:write for tcp-read. Dropping packet :( \n", url);
fprintf(stderr, "No fd for URL %s in udp:write for tcp-read. Dropping packet %d :( \n", url, dp->idx);
//mv_buffer_wtor (app_ctx, fdinfo, bp);
mv_buffer_atof (app_ctx, &dp->idx);
}

View file

@ -59,6 +59,10 @@ struct buffer_packet* get_read_buffer(struct algo_ctx *app_ctx, struct evt_core_
// 3. Update state
g_hash_table_insert(app_ctx->used_buffer, &(fdinfo->fd), bp);
// 4. Prepare packets
bp->mode = BP_READING;
bp->aread = 0;
bp->ap_count = 0;
return bp;
}
@ -81,6 +85,8 @@ struct buffer_packet* get_write_buffer(struct algo_ctx *app_ctx, struct evt_core
// 3. Update state
g_hash_table_insert(app_ctx->used_buffer, &(fdinfo->fd), bp);
bp->mode = BP_WRITING;
bp->awrite = 0;
return bp;
}

View file

@ -88,7 +88,7 @@ enum FD_STATE write_packet_to_udp(int fd, struct buffer_packet* bp, struct udp_t
enum FD_STATE read_packet_from_udp (int fd, struct buffer_packet* bp, struct udp_target* udp_t) {
ssize_t nread;
if (bp->mode != BP_READING) {
fprintf(stderr, "Buffer packet is not in reading mode\n");
fprintf(stderr, "Buffer packet is not in reading mode (mode: %d)\n", bp->mode);
return FDS_ERR;
}
@ -103,10 +103,16 @@ enum FD_STATE read_packet_from_udp (int fd, struct buffer_packet* bp, struct udp
(struct sockaddr*)&udp_t->addr,
&addrlen);
if ((int)nread > (int)udp_packet_size) return FDS_ERR;
if ((int)nread > (int)udp_packet_size) {
fprintf(stderr, "Packet has been truncated (%ld instead of %d)\n", nread, (int)udp_packet_size);
return FDS_ERR;
}
if (nread == -1 && errno == EAGAIN) return FDS_AGAIN;
if (nread == -1 && errno == EAGAIN) return FDS_AGAIN;
if (nread == -1) return FDS_ERR;
if (nread == -1) {
fprintf(stderr, "A system error occured\n");
return FDS_ERR;
}
udp_t->set = 1;
udp_t->addrlen = addrlen;