Commit 7a675c1b authored by Vinay K. Nallamothu's avatar Vinay K. Nallamothu Committed by David S. Miller

[NETROM]: Timer code cleanup.

parent a0aaef1c
......@@ -62,6 +62,7 @@ static HLIST_HEAD(nr_list);
static spinlock_t nr_list_lock = SPIN_LOCK_UNLOCKED;
static struct proto_ops nr_proto_ops;
void nr_init_timers(struct sock *sk);
static struct sock *nr_alloc_sock(void)
{
......@@ -279,17 +280,12 @@ void nr_destroy_socket(struct sock *sk)
kfree_skb(skb);
}
while ((skb = skb_dequeue(&sk->sk_write_queue)) != NULL) {
kfree_skb(skb);
}
if (atomic_read(&sk->sk_wmem_alloc) ||
atomic_read(&sk->sk_rmem_alloc)) {
/* Defer: outstanding buffers */
init_timer(&sk->sk_timer);
sk->sk_timer.expires = jiffies + 2 * HZ;
sk->sk_timer.function = nr_destroy_timer;
sk->sk_timer.data = (unsigned long)sk;
sk->sk_timer.expires = jiffies + 2 * HZ;
add_timer(&sk->sk_timer);
} else
sock_put(sk);
......@@ -442,10 +438,7 @@ static int nr_create(struct socket *sock, int protocol)
skb_queue_head_init(&nr->reseq_queue);
skb_queue_head_init(&nr->frag_queue);
init_timer(&nr->t1timer);
init_timer(&nr->t2timer);
init_timer(&nr->t4timer);
init_timer(&nr->idletimer);
nr_init_timers(sk);
nr->t1 = sysctl_netrom_transport_timeout;
nr->t2 = sysctl_netrom_transport_acknowledge_delay;
......@@ -491,10 +484,7 @@ static struct sock *nr_make_new(struct sock *osk)
skb_queue_head_init(&nr->reseq_queue);
skb_queue_head_init(&nr->frag_queue);
init_timer(&nr->t1timer);
init_timer(&nr->t2timer);
init_timer(&nr->t4timer);
init_timer(&nr->idletimer);
nr_init_timers(sk);
onr = nr_sk(osk);
......
......@@ -14,19 +14,17 @@
#include <net/netrom.h>
#include <linux/init.h>
static struct sk_buff_head loopback_queue;
static struct timer_list loopback_timer;
static void nr_loopback_timer(unsigned long);
static void nr_set_loopback_timer(void);
static struct sk_buff_head loopback_queue;
static struct timer_list loopback_timer = TIMER_INITIALIZER(nr_loopback_timer, 0, 0);
void nr_loopback_init(void)
void __init nr_loopback_init(void)
{
skb_queue_head_init(&loopback_queue);
init_timer(&loopback_timer);
}
static int nr_loopback_running(void)
static inline int nr_loopback_running(void)
{
return timer_pending(&loopback_timer);
}
......@@ -42,26 +40,13 @@ int nr_loopback_queue(struct sk_buff *skb)
skb_queue_tail(&loopback_queue, skbn);
if (!nr_loopback_running())
nr_set_loopback_timer();
mod_timer(&loopback_timer, jiffies + 10);
}
kfree_skb(skb);
return 1;
}
static void nr_loopback_timer(unsigned long);
static void nr_set_loopback_timer(void)
{
del_timer(&loopback_timer);
loopback_timer.data = 0;
loopback_timer.function = &nr_loopback_timer;
loopback_timer.expires = jiffies + 10;
add_timer(&loopback_timer);
}
static void nr_loopback_timer(unsigned long param)
{
struct sk_buff *skb;
......@@ -80,12 +65,12 @@ static void nr_loopback_timer(unsigned long param)
dev_put(dev);
if (!skb_queue_empty(&loopback_queue) && !nr_loopback_running())
nr_set_loopback_timer();
mod_timer(&loopback_timer, jiffies + 10);
}
}
void __exit nr_loopback_clear(void)
{
del_timer(&loopback_timer);
del_timer_sync(&loopback_timer);
skb_queue_purge(&loopback_queue);
}
......@@ -36,69 +36,63 @@ static void nr_t2timer_expiry(unsigned long);
static void nr_t4timer_expiry(unsigned long);
static void nr_idletimer_expiry(unsigned long);
void nr_start_t1timer(struct sock *sk)
void nr_init_timers(struct sock *sk)
{
nr_cb *nr = nr_sk(sk);
del_timer(&nr->t1timer);
init_timer(&nr->t1timer);
nr->t1timer.data = (unsigned long)sk;
nr->t1timer.function = &nr_t1timer_expiry;
nr->t1timer.expires = jiffies + nr->t1;
add_timer(&nr->t1timer);
init_timer(&nr->t2timer);
nr->t2timer.data = (unsigned long)sk;
nr->t2timer.function = &nr_t2timer_expiry;
init_timer(&nr->t4timer);
nr->t4timer.data = (unsigned long)sk;
nr->t4timer.function = &nr_t4timer_expiry;
init_timer(&nr->idletimer);
nr->idletimer.data = (unsigned long)sk;
nr->idletimer.function = &nr_idletimer_expiry;
/* initialized by sock_init_data */
sk->sk_timer.data = (unsigned long)sk;
sk->sk_timer.function = &nr_heartbeat_expiry;
}
void nr_start_t2timer(struct sock *sk)
void nr_start_t1timer(struct sock *sk)
{
nr_cb *nr = nr_sk(sk);
del_timer(&nr->t2timer);
mod_timer(&nr->t1timer, jiffies + nr->t1);
}
nr->t2timer.data = (unsigned long)sk;
nr->t2timer.function = &nr_t2timer_expiry;
nr->t2timer.expires = jiffies + nr->t2;
void nr_start_t2timer(struct sock *sk)
{
nr_cb *nr = nr_sk(sk);
add_timer(&nr->t2timer);
mod_timer(&nr->t2timer, jiffies + nr->t2);
}
void nr_start_t4timer(struct sock *sk)
{
nr_cb *nr = nr_sk(sk);
del_timer(&nr->t4timer);
nr->t4timer.data = (unsigned long)sk;
nr->t4timer.function = &nr_t4timer_expiry;
nr->t4timer.expires = jiffies + nr->t4;
add_timer(&nr->t4timer);
mod_timer(&nr->t4timer, jiffies + nr->t4);
}
void nr_start_idletimer(struct sock *sk)
{
nr_cb *nr = nr_sk(sk);
del_timer(&nr->idletimer);
if (nr->idle > 0) {
nr->idletimer.data = (unsigned long)sk;
nr->idletimer.function = &nr_idletimer_expiry;
nr->idletimer.expires = jiffies + nr->idle;
add_timer(&nr->idletimer);
}
if (nr->idle > 0)
mod_timer(&nr->idletimer, jiffies + nr->idle);
}
void nr_start_heartbeat(struct sock *sk)
{
del_timer(&sk->sk_timer);
sk->sk_timer.data = (unsigned long)sk;
sk->sk_timer.function = &nr_heartbeat_expiry;
sk->sk_timer.expires = jiffies + 5 * HZ;
add_timer(&sk->sk_timer);
mod_timer(&sk->sk_timer, jiffies + 5 * HZ);
}
void nr_stop_t1timer(struct sock *sk)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment