Clean code
This commit is contained in:
parent
0c50ca5a42
commit
5fdfd9aa9a
2 changed files with 8 additions and 5 deletions
|
@ -23,8 +23,10 @@ int algo_dup2_on_stream(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo
|
||||||
union abstract_packet *ap = (union abstract_packet*) &bp->ip;
|
union abstract_packet *ap = (union abstract_packet*) &bp->ip;
|
||||||
struct dup2_ctx* dup2c = app_ctx->misc;
|
struct dup2_ctx* dup2c = app_ctx->misc;
|
||||||
int32_t id = -1, port = -1;
|
int32_t id = -1, port = -1;
|
||||||
if (ctx->verbose > 1) fprintf(stderr, " [algo_dup2] Received a buffer\n");
|
if (ctx->verbose > 1) {
|
||||||
|
fprintf(stderr, " [algo_dup2] Received a buffer\n");
|
||||||
dump_buffer_packet(bp);
|
dump_buffer_packet(bp);
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
switch (ap->fmt.headers.cmd) {
|
switch (ap->fmt.headers.cmd) {
|
||||||
|
@ -85,8 +87,10 @@ int algo_dup2_on_datagram(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdin
|
||||||
.fmt.content.udp_metadata_thunder.id = dup2c->emit_id
|
.fmt.content.udp_metadata_thunder.id = dup2c->emit_id
|
||||||
};
|
};
|
||||||
buffer_append_ap (bp, &metadata);
|
buffer_append_ap (bp, &metadata);
|
||||||
|
if (ctx->verbose > 1) {
|
||||||
dump_buffer_packet(bp);
|
dump_buffer_packet(bp);
|
||||||
if (ctx->verbose > 1) fprintf(stderr, " [algo_dup2] Added metadata\n");
|
fprintf(stderr, " [algo_dup2] Added metadata\n");
|
||||||
|
}
|
||||||
|
|
||||||
struct evt_core_cat* cat = evt_core_get_from_cat (ctx, "tcp-write");
|
struct evt_core_cat* cat = evt_core_get_from_cat (ctx, "tcp-write");
|
||||||
for (int i = 0; i < app_ctx->ap.links; i++) {
|
for (int i = 0; i < app_ctx->ap.links; i++) {
|
||||||
|
|
|
@ -68,7 +68,6 @@ enum FD_STATE read_packet_from_tcp(struct evt_core_fdinfo* fdinfo, struct buffer
|
||||||
//fprintf(stderr, "[content] bp_aread=%d, prev_ap_aread=%ld, cur_ap_aread=%ld\n", bp->aread, ap_aread, cur_ap_aread);
|
//fprintf(stderr, "[content] bp_aread=%d, prev_ap_aread=%ld, cur_ap_aread=%ld\n", bp->aread, ap_aread, cur_ap_aread);
|
||||||
while (cur_ap_aread < ap->fmt.headers.size) {
|
while (cur_ap_aread < ap->fmt.headers.size) {
|
||||||
nread = read(fdinfo->fd, &(ap->raw) + cur_ap_aread, ap->fmt.headers.size - cur_ap_aread);
|
nread = read(fdinfo->fd, &(ap->raw) + cur_ap_aread, ap->fmt.headers.size - cur_ap_aread);
|
||||||
perror("read ap");
|
|
||||||
if (nread == 0) return FDS_AGAIN;
|
if (nread == 0) return FDS_AGAIN;
|
||||||
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) return FDS_ERR;
|
||||||
|
|
Loading…
Reference in a new issue