Also speed up naive algorithm!
This commit is contained in:
parent
df4e56775d
commit
9c606c2162
2 changed files with 4 additions and 6 deletions
|
@ -45,7 +45,6 @@ int algo_dup2_on_stream(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo
|
|||
}
|
||||
|
||||
int algo_dup2_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) {
|
||||
char* url[] = { "tcp:write:127.0.0.1:7500", "tcp:write:127.0.0.1:7501" };
|
||||
struct evt_core_fdinfo *to_fdinfo = NULL;
|
||||
struct algo_ctx* app_ctx = fdinfo->cat->app_ctx;
|
||||
|
||||
|
@ -59,7 +58,7 @@ int algo_dup2_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdin
|
|||
// 1. A whole packet has been read, we will find someone to write it
|
||||
to_fdinfo = g_array_index(cat->socklist, struct evt_core_fdinfo*, i);
|
||||
if (to_fdinfo == NULL) {
|
||||
fprintf(stderr, "No fd for URL %s in udp-read.\n", url[i]);
|
||||
fprintf(stderr, "No fd for cat %s in udp-read.\n", cat->name);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,15 +27,14 @@ int algo_naive_on_stream(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinf
|
|||
}
|
||||
|
||||
int algo_naive_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp) {
|
||||
char url[256];
|
||||
struct evt_core_fdinfo *to_fdinfo = NULL;
|
||||
struct algo_ctx* app_ctx = fdinfo->cat->app_ctx;
|
||||
|
||||
// 1. 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);
|
||||
struct evt_core_cat* cat = evt_core_get_from_cat (ctx, "tcp-write");
|
||||
to_fdinfo = g_array_index(cat->socklist, struct evt_core_fdinfo*, 0);
|
||||
if (to_fdinfo == NULL) {
|
||||
fprintf(stderr, "No fd for URL %s in udp-read. Dropping packet :( \n", url);
|
||||
fprintf(stderr, "No fd for cat %s in udp-read. Dropping packet :( \n", cat->name);
|
||||
mv_buffer_wtof (app_ctx, fdinfo);
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue