diff options
author | Greg Hudson <ghudson@mit.edu> | 1998-09-02 21:37:33 +0000 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 1998-09-02 21:37:33 +0000 |
commit | a37c099d4b2633186993127d647ad2285af62fa9 (patch) | |
tree | 7db77ba64484fce824f646a32c2d37961af305e2 /server/dispatch.c | |
parent | f3b7608fc2f87bb8fbed17e8308a109fc4b91a78 (diff) |
Keep track of how responsive clients have been and don't time out good ones.
Diffstat (limited to 'server/dispatch.c')
-rw-r--r-- | server/dispatch.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/server/dispatch.c b/server/dispatch.c index 4519812..5659516 100644 --- a/server/dispatch.c +++ b/server/dispatch.c @@ -499,9 +499,7 @@ nack_release(client) for (i = 0; i < NACKTAB_HASHSIZE; i++) { for (nacked = nacktab[i]; nacked; nacked = next) { next = nacked->next; - if (nacked->dest.addr.sin_addr.s_addr == - client->addr.sin_addr.s_addr && - nacked->dest.addr.sin_port == client->addr.sin_port) { + if (nacked->client == client) { timer_reset(nacked->timer); LIST_DELETE(nacked); free(nacked->packet); @@ -558,6 +556,7 @@ xmit_frag(notice, buf, len, waitforack) memcpy(savebuf, buf, len); sin = ZGetDestAddr(); + nacked->client = NULL; nacked->rexmits = (sendfail) ? -1 : 0; nacked->packet = savebuf; nacked->dest.addr = sin; @@ -660,6 +659,7 @@ xmit(notice, dest, auth, client) return; } + nacked->client = client; nacked->rexmits = (sendfail) ? -1 : 0; nacked->packet = noticepack; nacked->dest.addr = *dest; @@ -681,7 +681,6 @@ rexmit(arg) { Unacked *nacked = (Unacked *) arg; int retval; - Client *client; #if 1 syslog(LOG_DEBUG, "rexmit %s/%d #%d time %d", @@ -691,22 +690,23 @@ rexmit(arg) nacked->rexmits++; if (rexmit_times[nacked->rexmits] == -1) { - /* Unresponsive client, find it in our database. */ - client = client_find(&nacked->dest.addr.sin_addr, - nacked->dest.addr.sin_port); - - /* unlink & free nacked */ - LIST_DELETE(nacked); - free(nacked->packet); - free(nacked); - - /* Kill the client. */ - if (client) { - server_kill_clt(client); - client_deregister(client, 1); + if (!nacked->client + || NOW - nacked->client->last_ack >= CLIENT_GIVEUP_MIN) { + /* The client (if there was one) has been unresponsive. Give up + * sending this packet, and kill the client if there was one. */ + LIST_DELETE(nacked); + free(nacked->packet); + free(nacked); + if (nacked->client) { + server_kill_clt(nacked->client); + client_deregister(nacked->client, 1); + } + return; + } else { + /* The client has sent us an ack recently. Retry with the maximum + * retransmit time. */ + nacked->rexmits--; } - - return; } /* retransmit the packet */ @@ -841,6 +841,8 @@ nack_cancel(notice, who) if (nacked->dest.addr.sin_addr.s_addr == who->sin_addr.s_addr && nacked->dest.addr.sin_port == who->sin_port && ZCompareUID(&nacked->uid, ¬ice->z_uid)) { + if (nacked->client) + nacked->client->last_ack = NOW; timer_reset(nacked->timer); free(nacked->packet); LIST_DELETE(nacked); |