Due to a logic bug in ack(), the FIN bit could be set on a too early packet,
if utcp_shutdown() was called with a full send buffer.
c->snd.nxt += seglen;
left -= seglen;
- if(c->state != ESTABLISHED && !left && seglen) {
+ if(c->state != ESTABLISHED && seglen && c->snd.nxt == c->snd.last) {
switch(c->state) {
case FIN_WAIT_1:
case CLOSING:
}
int utcp_shutdown(struct utcp_connection *c, int dir) {
- debug("%p shutdown %d\n", c ? c->utcp : NULL, dir);
+ debug("%p shutdown %d at %u\n", c ? c->utcp : NULL, dir, c->snd.last);
if(!c) {
errno = EFAULT;
return -1;
}
// TODO: handle dir
+ // TODO: check that repeated calls with the same parameters should have no effect
switch(c->state) {
case CLOSED: