Mercurial > ecos
diff packages/redboot/current/src/net/tcp.c @ 2867:05a4930e2f1a
* src/net/tcp.c (__tcp_abort): Ensure the connection is closed
before returning. This fixes a race condition which Ilko Iliev
<iliev@ronetix.at> found when performing two back to back http
transfers
| author | asl |
|---|---|
| date | Mon, 20 Apr 2009 11:19:16 +0000 |
| parents | 74dbf4c3f2e1 |
| children |
line wrap: on
line diff
--- a/packages/redboot/current/src/net/tcp.c +++ b/packages/redboot/current/src/net/tcp.c @@ -710,10 +710,27 @@ do_abort(void *s) unlink_socket((tcp_socket_t *)s); } +/* + * Abort a TCP connection, waiting for the connection to be closed, so + * it is save to reuse the tcp_socket_t structure. + */ + void __tcp_abort(tcp_socket_t *s, unsigned long delay) { + int timeout = 1000; + __timer_set(&abort_timer, delay, do_abort, s); + + while (s->state != _CLOSED) { + if (--timeout <= 0) { + diag_printf("TCP close - connection failed to close\n"); + return; + } + + MS_TICKS_DELAY(); + __tcp_poll(); + } } /*
