Skip to content

Commit

Permalink
network: rework network status callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
PolynomialDivision committed Jul 24, 2022
1 parent 10fb043 commit 9e8060e
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/network/tcpsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,11 @@ static void client_notify_state(struct ustream *s) {
dawnlog_debug_func("Entering...");

struct client *cl = container_of(s, struct client, s.stream);
if (!s->eof)
if (!s->write_error && !s->eof)
return;

dawnlog_error("eof!, pending: %d, total: %d\n", s->w.data_bytes, cl->ctr);

if (!s->w.data_bytes)
return client_close(s);

dawnlog_error("Closing client-connection, pending: %d, total: %d\n", s->w.data_bytes, cl->ctr);
client_close(s);
}

static void client_to_server_close(struct ustream *s) {
Expand All @@ -100,14 +97,11 @@ static void client_to_server_state(struct ustream *s) {

dawnlog_debug_func("Entering...");

if (!s->eof)
if (!s->write_error && !s->eof)
return;

dawnlog_error("eof!, pending: %d, total: %d\n", s->w.data_bytes, cl->ctr);

if (!s->w.data_bytes)
return client_to_server_close(s);

dawnlog_error("Closing connection, pending: %d, total: %d\n", s->w.data_bytes, cl->ctr);
client_to_server_close(s);
}

static void client_read_cb(struct ustream *s, int bytes) {
Expand Down

0 comments on commit 9e8060e

Please sign in to comment.