diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-11-07 09:08:07 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-11-07 09:08:07 +0000 |
commit | 29314de21e95fe74733eac127af221eba444eb57 (patch) | |
tree | 1ca5343efc3557a22d2a6f1e78c3752a8ad41988 /sys | |
parent | e11eaace99dc4ea0704b20e623af4f105fb168ee (diff) |
Use goto for consistently instead of splx() and return.
This will allow to have a single lock/unlock dance per timer.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/tcp_input.c | 9 | ||||
-rw-r--r-- | sys/netinet/tcp_timer.c | 38 |
2 files changed, 18 insertions, 29 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 2d06f541948..5fa4881a43f 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.329 2016/10/04 13:56:50 mpi Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.330 2016/11/07 09:08:05 mpi Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -3523,10 +3523,8 @@ syn_cache_timer(void *arg) int s; s = splsoftnet(); - if (sc->sc_flags & SCF_DEAD) { - splx(s); - return; - } + if (sc->sc_flags & SCF_DEAD) + goto out; if (__predict_false(sc->sc_rxtshift == TCP_MAXRXTSHIFT)) { /* Drop it -- too many retransmissions. */ @@ -3549,6 +3547,7 @@ syn_cache_timer(void *arg) sc->sc_rxtshift++; SYN_CACHE_TIMER_ARM(sc); + out: splx(s); return; diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index 6f4f07e70de..698cb0bb0c9 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_timer.c,v 1.50 2016/09/24 14:51:37 naddy Exp $ */ +/* $OpenBSD: tcp_timer.c,v 1.51 2016/11/07 09:08:06 mpi Exp $ */ /* $NetBSD: tcp_timer.c,v 1.14 1996/02/13 23:44:09 christos Exp $ */ /* @@ -112,14 +112,12 @@ tcp_delack(void *arg) * for whatever reason, it will restart the delayed * ACK callout. */ - s = splsoftnet(); - if (tp->t_flags & TF_DEAD) { - splx(s); - return; - } + if (tp->t_flags & TF_DEAD) + goto out; tp->t_flags |= TF_ACKNOW; (void) tcp_output(tp); + out: splx(s); } @@ -194,10 +192,8 @@ tcp_timer_rexmt(void *arg) int s; s = splsoftnet(); - if (tp->t_flags & TF_DEAD) { - splx(s); - return; - } + if (tp->t_flags & TF_DEAD) + goto out; if ((tp->t_flags & TF_PMTUD_PEND) && tp->t_inpcb && SEQ_GEQ(tp->t_pmtud_th_seq, tp->snd_una) && @@ -224,8 +220,7 @@ tcp_timer_rexmt(void *arg) sin.sin_addr = tp->t_inpcb->inp_faddr; in_pcbnotifyall(&tcbtable, sintosa(&sin), tp->t_inpcb->inp_rtableid, EMSGSIZE, tcp_mtudisc); - splx(s); - return; + goto out; } #ifdef TCP_SACK @@ -389,8 +384,7 @@ tcp_timer_persist(void *arg) s = splsoftnet(); if ((tp->t_flags & TF_DEAD) || TCP_TIMER_ISARMED(tp, TCPT_REXMT)) { - splx(s); - return; + goto out; } tcpstat.tcps_persisttimeo++; /* @@ -425,10 +419,8 @@ tcp_timer_keep(void *arg) int s; s = splsoftnet(); - if (tp->t_flags & TF_DEAD) { - splx(s); - return; - } + if (tp->t_flags & TF_DEAD) + goto out; tcpstat.tcps_keeptimeo++; if (TCPS_HAVEESTABLISHED(tp->t_state) == 0) @@ -457,14 +449,13 @@ tcp_timer_keep(void *arg) TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepintvl); } else TCP_TIMER_ARM(tp, TCPT_KEEP, tcp_keepidle); - + out: splx(s); return; dropit: tcpstat.tcps_keepdrops++; tp = tcp_drop(tp, ETIMEDOUT); - splx(s); } @@ -475,10 +466,8 @@ tcp_timer_2msl(void *arg) int s; s = splsoftnet(); - if (tp->t_flags & TF_DEAD) { - splx(s); - return; - } + if (tp->t_flags & TF_DEAD) + goto out; #ifdef TCP_SACK tcp_timer_freesack(tp); @@ -490,5 +479,6 @@ tcp_timer_2msl(void *arg) else tp = tcp_close(tp); + out: splx(s); } |