diff options
author | Ondrej Filip <feela@network.cz> | 2005-02-14 22:28:51 +0100 |
---|---|---|
committer | Ondrej Filip <feela@network.cz> | 2005-02-14 22:28:51 +0100 |
commit | 7c49f715593ad7bbe0a4fb86284e2023f7b65bc1 (patch) | |
tree | ab18a4fe334e6d2f3d2ef22458e4e31fff9556e4 | |
parent | 030d3b387edae4a30fb524ed839be020b7b8df8e (diff) | |
download | bird-7c49f715593ad7bbe0a4fb86284e2023f7b65bc1.tar bird-7c49f715593ad7bbe0a4fb86284e2023f7b65bc1.zip |
Added s->err_hook wrapper that empties socket.
-rw-r--r-- | sysdep/unix/io.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c index 5ecc8ae..d34ff2f 100644 --- a/sysdep/unix/io.c +++ b/sysdep/unix/io.c @@ -75,6 +75,13 @@ tracked_fopen(pool *p, char *name, char *mode) return f; } +void +c_err_hook(struct birdsock *s, int err) +{ + s->ttx = s->tpos; /* empty tx buffer */ + s->err_hook(s, err); +} + /** * DOC: Timers * @@ -680,7 +687,7 @@ sk_passive_connected(sock *s, struct sockaddr *sa, int al, int type) else if (errno != EINTR && errno != EAGAIN) { log(L_ERR "accept: %m"); - s->err_hook(s, errno); + c_err_hook(s, errno); } return 0; } @@ -898,7 +905,7 @@ sk_maybe_write(sock *s) { if (errno != EINTR && errno != EAGAIN) { - s->err_hook(s, errno); + c_err_hook(s, errno); return -1; } return 0; @@ -923,7 +930,7 @@ sk_maybe_write(sock *s) { if (errno != EINTR && errno != EAGAIN) { - s->err_hook(s, errno); + c_err_hook(s, errno); return -1; } return 0; @@ -1001,10 +1008,10 @@ sk_read(sock *s) if (c < 0) { if (errno != EINTR && errno != EAGAIN) - s->err_hook(s, errno); + c_err_hook(s, errno); } else if (!c) - s->err_hook(s, 0); + c_err_hook(s, 0); else { s->rpos += c; @@ -1029,7 +1036,7 @@ sk_read(sock *s) if (e < 0) { if (errno != EINTR && errno != EAGAIN) - s->err_hook(s, errno); + c_err_hook(s, errno); return 0; } s->rpos = s->rbuf + e; @@ -1052,7 +1059,7 @@ sk_write(sock *s) if (connect(s->fd, (struct sockaddr *) &sa, sizeof(sa)) >= 0 || errno == EISCONN) sk_tcp_connected(s); else if (errno != EINTR && errno != EAGAIN && errno != EINPROGRESS) - s->err_hook(s, errno); + c_err_hook(s, errno); return 0; } default: |