Drop packet instead of crashing

This commit is contained in:
Quentin Dufour 2019-02-19 19:31:26 +01:00
parent 603c67b1d9
commit 7914c4fc13

View file

@ -166,7 +166,11 @@ void on_tcp_read(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
// 3. A whole packet has been read, we will find someone to write it
sprintf(url, "udp:write:127.0.0.1:%d", bp->ip.ap.str.port);
to_fdinfo = evt_core_get_from_url (ctx, url);
if (to_fdinfo == NULL) goto co_error;
if (to_fdinfo == NULL) {
fprintf(stderr, "No fd for URL %s in tcp-read. Dropping packet :( \n", url);
mv_buffer_wtor (app_ctx, fdinfo, bp);
return;
}
// 4. We move the buffer and notify the target
mv_buffer_rtow (app_ctx, fdinfo, to_fdinfo, bp);
@ -223,7 +227,11 @@ void on_udp_read(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
// 3. A whole packet has been read, we will find someone to write it
sprintf(url, "tcp:write:127.0.0.1:7500");
to_fdinfo = evt_core_get_from_url (ctx, url);
if (to_fdinfo == NULL) goto co_error;
if (to_fdinfo == NULL) {
fprintf(stderr, "No fd for URL %s in udp-read. Dropping packet :( \n", url);
mv_buffer_wtor (app_ctx, fdinfo, bp);
return;
}
// 4. We move the buffer and notify the target
mv_buffer_rtow (app_ctx, fdinfo, to_fdinfo, bp);