Some debug + reset buffers
This commit is contained in:
parent
2d0f285bc2
commit
33ba4b2d55
3 changed files with 16 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
12
src/packet.c
12
src/packet.c
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue