Skip to content

Commit

Permalink
fixed old code
Browse files Browse the repository at this point in the history
  • Loading branch information
radkesvat committed May 2, 2024
1 parent 50b52e6 commit e885a08
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions tunnels/logger/logger_tunnel.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "logger_tunnel.h"
#include "buffer_pool.h"
#include "loggers/network_logger.h"
#include "tunnel.h"

#undef min
static inline size_t min(size_t x, size_t y)
Expand Down Expand Up @@ -33,15 +34,15 @@ static void upStream(tunnel_t *self, context_t *c)
{

// send back something
// {
// context_t *reply = newContextFrom(c);
// reply->payload = popBuffer(getContextBufferPool(c));
// reuseContextBuffer(c);
// destroyContext(c);
// sprintf((char *) rawBuf(reply->payload), "%s", "salam");
// setLen(reply->payload, strlen("salam"));
// self->dw->downStream(self->dw, reply);
// }
{
context_t *reply = newContextFrom(c);
reply->payload = popBuffer(getContextBufferPool(c));
reuseContextBuffer(c);
destroyContext(c);
sprintf((char *) rawBuf(reply->payload), "%s", "salam");
setLen(reply->payload, strlen("salam"));
self->dw->downStream(self->dw, reply);
}

}
}
Expand All @@ -56,13 +57,13 @@ static void upStream(tunnel_t *self, context_t *c)
}
else
{
context_t *replyx = newContextFrom(c);
context_t *est_reply = newContextFrom(c);
destroyContext(c);
replyx->est = true;
self->dw->downStream(self->dw, replyx);
est_reply->est = true;
self->dw->downStream(self->dw, est_reply);
}
}
if (c->fin)
else if (c->fin)
{
LOGD("upstream fin");
if (self->up != NULL)
Expand Down Expand Up @@ -121,20 +122,24 @@ static void downStream(tunnel_t *self, context_t *c)
self->up->upStream(self->up, reply);
}
}
if (c->fin)
else if (c->fin)
{
LOGD("downstream fin");
if (self->dw != NULL)
{
self->dw->downStream(self->dw, c);
}else {
destroyContext(c);
}
}
if (c->est)
else if (c->est)
{
LOGD("downstream est");
if (self->dw != NULL)
{
self->dw->downStream(self->dw, c);
}else {
destroyContext(c);
}
}
}
Expand Down

0 comments on commit e885a08

Please sign in to comment.