[PATCH] DCCP: remove timeo from output.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/5/06, Gerrit Renker <gerrit@xxxxxxxxxxxxxx> wrote:
                        } else {
                                err = dccp_wait_for_ccid(sk, skb, &timeo);
                                timeo = DCCP_XMIT_TIMEO;          /* <==== I think you mean this one */
                        }


Yes I did mean that one


|  Anyway feel free to write a patch or I might when I get home from work
|  or tomorrow
I'd be happy to see a patch - maybe several cases can be folded into one.

Sending as attachment to message as mailer will mangle here I think -
reproduced below inline but I know gmail will mangle for sure. Compile
tested only as at work but I think I understand this code pretty well
and simplifying only. Removes the need for your patch altogether.

commit ab874add9a959d5b8a74ea654ad3c463da621bc0
Author: Ian McDonald <ian.mcdonald@xxxxxxxxxxx>
Date:   Tue Dec 5 10:48:49 2006 +1300

This patch simplifies things a lot by removing timeo as not needed.

Other simplifications flow on from this such as removing constants.

As a result of this EAGAIN is not returned any more.

Inspired by Gerrit Renker

Signed-off-by: Ian McDonald <ian.mcdonald@xxxxxxxxxxx>

diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 6888698..44829d6 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -80,8 +80,6 @@ extern void dccp_time_wait(struct sock *sk, int
state, int timeo);

#define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */

-#define DCCP_XMIT_TIMEO 30000 /* Time/msecs for blocking transmit per packet */
-
/* sysctl variables for DCCP */
extern int  sysctl_dccp_request_retries;
extern int  sysctl_dccp_retries1;
diff --git a/net/dccp/output.c b/net/dccp/output.c
index 400c30b..c4460f6 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -177,12 +177,11 @@ void dccp_write_space(struct sock *sk)
 * @sk: socket to wait for
 * @timeo: for how long
 */
-static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb,
-			      long *timeo)
+static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb)
{
	struct dccp_sock *dp = dccp_sk(sk);
	DEFINE_WAIT(wait);
-	long delay;
+	unsigned long delay;
	int rc;

	while (1) {
@@ -190,8 +189,6 @@ static int dccp_wait_for_ccid(struct sock *sk,
struct sk_buff *skb,

		if (sk->sk_err)
			goto do_error;
-		if (!*timeo)
-			goto do_nonblock;
		if (signal_pending(current))
			goto do_interrupted;

@@ -199,12 +196,9 @@ static int dccp_wait_for_ccid(struct sock *sk,
struct sk_buff *skb,
		if (rc <= 0)
			break;
		delay = msecs_to_jiffies(rc);
-		if (delay > *timeo || delay < 0)
-			goto do_nonblock;
-
		sk->sk_write_pending++;
		release_sock(sk);
-		*timeo -= schedule_timeout(delay);
+		schedule_timeout(delay);
		lock_sock(sk);
		sk->sk_write_pending--;
	}
@@ -215,11 +209,8 @@ out:
do_error:
	rc = -EPIPE;
	goto out;
-do_nonblock:
-	rc = -EAGAIN;
-	goto out;
do_interrupted:
-	rc = sock_intr_errno(*timeo);
+	rc = -EINTR;
	goto out;
}

@@ -240,8 +231,6 @@ void dccp_write_xmit(struct sock *sk, int block)
{
	struct dccp_sock *dp = dccp_sk(sk);
	struct sk_buff *skb;
-	long timeo = DCCP_XMIT_TIMEO; 	/* If a packet is taking longer than
-					   this we have other issues */

	while ((skb = skb_peek(&sk->sk_write_queue))) {
		int err = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb);
@@ -251,10 +240,8 @@ void dccp_write_xmit(struct sock *sk, int block)
				sk_reset_timer(sk, &dp->dccps_xmit_timer,
						msecs_to_jiffies(err)+jiffies);
				break;
-			} else {
-				err = dccp_wait_for_ccid(sk, skb, &timeo);
-				timeo = DCCP_XMIT_TIMEO;
-			}
+			} else
+				err = dccp_wait_for_ccid(sk, skb);
			if (err)
				DCCP_BUG("err=%d after dccp_wait_for_ccid", err);
		}
commit ab874add9a959d5b8a74ea654ad3c463da621bc0
Author: Ian McDonald <ian.mcdonald@xxxxxxxxxxx>
Date:   Tue Dec 5 10:48:49 2006 +1300

This patch simplifies things a lot by removing timeo as not needed.
    
Other simplifications flow on from this such as removing constants.
    
As a result of this EAGAIN is not returned any more.
    
Inspired by Gerrit Renker
    
Signed-off-by: Ian McDonald <ian.mcdonald@xxxxxxxxxxx>

diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h
index 6888698..44829d6 100644
--- a/net/dccp/dccp.h
+++ b/net/dccp/dccp.h
@@ -80,8 +80,6 @@ extern void dccp_time_wait(struct sock *sk, int state, int timeo);
 
 #define DCCP_RTO_MAX ((unsigned)(120 * HZ)) /* FIXME: using TCP value */
 
-#define DCCP_XMIT_TIMEO 30000 /* Time/msecs for blocking transmit per packet */
-
 /* sysctl variables for DCCP */
 extern int  sysctl_dccp_request_retries;
 extern int  sysctl_dccp_retries1;
diff --git a/net/dccp/output.c b/net/dccp/output.c
index 400c30b..c4460f6 100644
--- a/net/dccp/output.c
+++ b/net/dccp/output.c
@@ -177,12 +177,11 @@ void dccp_write_space(struct sock *sk)
  * @sk: socket to wait for
  * @timeo: for how long
  */
-static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb,
-			      long *timeo)
+static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb)
 {
 	struct dccp_sock *dp = dccp_sk(sk);
 	DEFINE_WAIT(wait);
-	long delay;
+	unsigned long delay;
 	int rc;
 
 	while (1) {
@@ -190,8 +189,6 @@ static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb,
 
 		if (sk->sk_err)
 			goto do_error;
-		if (!*timeo)
-			goto do_nonblock;
 		if (signal_pending(current))
 			goto do_interrupted;
 
@@ -199,12 +196,9 @@ static int dccp_wait_for_ccid(struct sock *sk, struct sk_buff *skb,
 		if (rc <= 0)
 			break;
 		delay = msecs_to_jiffies(rc);
-		if (delay > *timeo || delay < 0)
-			goto do_nonblock;
-
 		sk->sk_write_pending++;
 		release_sock(sk);
-		*timeo -= schedule_timeout(delay);
+		schedule_timeout(delay);
 		lock_sock(sk);
 		sk->sk_write_pending--;
 	}
@@ -215,11 +209,8 @@ out:
 do_error:
 	rc = -EPIPE;
 	goto out;
-do_nonblock:
-	rc = -EAGAIN;
-	goto out;
 do_interrupted:
-	rc = sock_intr_errno(*timeo);
+	rc = -EINTR;
 	goto out;
 }
 
@@ -240,8 +231,6 @@ void dccp_write_xmit(struct sock *sk, int block)
 {
 	struct dccp_sock *dp = dccp_sk(sk);
 	struct sk_buff *skb;
-	long timeo = DCCP_XMIT_TIMEO; 	/* If a packet is taking longer than
-					   this we have other issues */
 
 	while ((skb = skb_peek(&sk->sk_write_queue))) {
 		int err = ccid_hc_tx_send_packet(dp->dccps_hc_tx_ccid, sk, skb);
@@ -251,10 +240,8 @@ void dccp_write_xmit(struct sock *sk, int block)
 				sk_reset_timer(sk, &dp->dccps_xmit_timer,
 						msecs_to_jiffies(err)+jiffies);
 				break;
-			} else {
-				err = dccp_wait_for_ccid(sk, skb, &timeo);
-				timeo = DCCP_XMIT_TIMEO;
-			}
+			} else
+				err = dccp_wait_for_ccid(sk, skb);
 			if (err)
 				DCCP_BUG("err=%d after dccp_wait_for_ccid", err);
 		}

[Index of Archives]     [Linux Kernel]     [IETF DCCP]     [Linux Networking]     [Git]     [Security]     [Linux Assembly]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux