aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/proto.c
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2008-09-04 01:30:19 -0400
committerGerrit Renker <gerrit@erg.abdn.ac.uk>2008-09-04 01:45:38 -0400
commit146993cf5174472644ed11bd5fb539f0af8bfa49 (patch)
treeb2c5343ad610fe113425a3663f0dc3ddb478911b /net/dccp/proto.c
parente7937772d7a2b0127cc4cbc67bc594e139fdaf63 (diff)
dccp: Refine the wait-for-ccid mechanism
This extends the existing wait-for-ccid routine so that it may be used with different types of CCID. It further addresses the problems listed below. The code looks if the write queue is non-empty and grants the TX CCID up to `timeout' jiffies to drain the queue. It will instead purge that queue if * the delay suggested by the CCID exceeds the time budget; * a socket error occurred while waiting for the CCID; * there is a signal pending (eg. annoyed user pressed Control-C); * the CCID does not support delays (we don't know how long it will take). D e t a i l s [can be removed] ------------------------------- DCCP's sending mechanism functions a bit like non-blocking I/O: dccp_sendmsg() will enqueue up to net.dccp.default.tx_qlen packets (default=5), without waiting for them to be released to the network. Rate-based CCIDs, such as CCID3/4, can impose sending delays of up to maximally 64 seconds (t_mbi in RFC 3448). Hence the write queue may still contain packets when the application closes. Since the write queue is congestion-controlled by the CCID, draining the queue is also under control of the CCID. There are several problems that needed to be addressed: 1) The queue-drain mechanism only works with rate-based CCIDs. If CCID2 for example has a full TX queue and becomes network-limited just as the application wants to close, then waiting for CCID2 to become unblocked could lead to an indefinite delay (i.e., application "hangs"). 2) Since each TX CCID in turn uses a feedback mechanism, there may be changes in its sending policy while the queue is being drained. This can lead to further delays during which the application will not be able to terminate. 3) The minimum wait time for CCID3/4 can be expected to be the queue length times the current inter-packet delay. For example if tx_qlen=100 and a delay of 15 ms is used for each packet, then the application would have to wait for a minimum of 1.5 seconds before being allowed to exit. 4) There is no way for the user/application to control this behaviour. It would be good to use the timeout argument of dccp_close() as an upper bound. Then the maximum time that an application is willing to wait for its CCIDs to can be set via the SO_LINGER option. These problems are addressed by giving the CCID a grace period of up to the `timeout' value. The wait-for-ccid function is, as before, used when the application (a) has read all the data in its receive buffer and (b) if SO_LINGER was set with a non-zero linger time, or (c) the socket is either in the OPEN (active close) or in the PASSIVE_CLOSEREQ state (client application closes after receiving CloseReq). In addition, there is a catch-all case by calling __skb_queue_purge() after waiting for the CCID. This is necessary since the write queue may still have data when (a) the host has been passively-closed, (b) abnormal termination (unread data, zero linger time), (c) wait-for-ccid could not finish within the given time limit. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Diffstat (limited to 'net/dccp/proto.c')
-rw-r--r--net/dccp/proto.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 11905e0cf8f7..8c125ffab1c5 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -735,7 +735,7 @@ int dccp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
735 goto out_discard; 735 goto out_discard;
736 736
737 skb_queue_tail(&sk->sk_write_queue, skb); 737 skb_queue_tail(&sk->sk_write_queue, skb);
738 dccp_write_xmit(sk,0); 738 dccp_write_xmit(sk);
739out_release: 739out_release:
740 release_sock(sk); 740 release_sock(sk);
741 return rc ? : len; 741 return rc ? : len;
@@ -958,9 +958,22 @@ void dccp_close(struct sock *sk, long timeout)
958 /* Check zero linger _after_ checking for unread data. */ 958 /* Check zero linger _after_ checking for unread data. */
959 sk->sk_prot->disconnect(sk, 0); 959 sk->sk_prot->disconnect(sk, 0);
960 } else if (sk->sk_state != DCCP_CLOSED) { 960 } else if (sk->sk_state != DCCP_CLOSED) {
961 /*
962 * Normal connection termination. May need to wait if there are
963 * still packets in the TX queue that are delayed by the CCID.
964 */
965 dccp_flush_write_queue(sk, &timeout);
961 dccp_terminate_connection(sk); 966 dccp_terminate_connection(sk);
962 } 967 }
963 968
969 /*
970 * Flush write queue. This may be necessary in several cases:
971 * - we have been closed by the peer but still have application data;
972 * - abortive termination (unread data or zero linger time),
973 * - normal termination but queue could not be flushed within time limit
974 */
975 __skb_queue_purge(&sk->sk_write_queue);
976
964 sk_stream_wait_close(sk, timeout); 977 sk_stream_wait_close(sk, timeout);
965 978
966adjudge_to_death: 979adjudge_to_death: