diff options
author | Arnaldo Carvalho de Melo <acme@ghostprotocols.net> | 2005-08-09 22:45:38 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2005-08-29 18:37:29 -0400 |
commit | e6848976b721eeb5551cd94673faafeef78d9f35 (patch) | |
tree | 6c78b0eb52614ff6386b603ca64091b5aefaa418 /net/ipv4 | |
parent | d13964f4490157b8a290903362bfbc54f750a6bc (diff) |
[NET]: Cleanup INET_REFCNT_DEBUG code
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/af_inet.c | 18 | ||||
-rw-r--r-- | net/ipv4/tcp.c | 7 | ||||
-rw-r--r-- | net/ipv4/tcp_minisocks.c | 20 |
3 files changed, 19 insertions, 26 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 163ae4068b5f..9e83d7773d8f 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -114,10 +114,6 @@ | |||
114 | 114 | ||
115 | DEFINE_SNMP_STAT(struct linux_mib, net_statistics); | 115 | DEFINE_SNMP_STAT(struct linux_mib, net_statistics); |
116 | 116 | ||
117 | #ifdef INET_REFCNT_DEBUG | ||
118 | atomic_t inet_sock_nr; | ||
119 | #endif | ||
120 | |||
121 | extern void ip_mc_drop_socket(struct sock *sk); | 117 | extern void ip_mc_drop_socket(struct sock *sk); |
122 | 118 | ||
123 | /* The inetsw table contains everything that inet_create needs to | 119 | /* The inetsw table contains everything that inet_create needs to |
@@ -153,11 +149,7 @@ void inet_sock_destruct(struct sock *sk) | |||
153 | if (inet->opt) | 149 | if (inet->opt) |
154 | kfree(inet->opt); | 150 | kfree(inet->opt); |
155 | dst_release(sk->sk_dst_cache); | 151 | dst_release(sk->sk_dst_cache); |
156 | #ifdef INET_REFCNT_DEBUG | 152 | sk_refcnt_debug_dec(sk); |
157 | atomic_dec(&inet_sock_nr); | ||
158 | printk(KERN_DEBUG "INET socket %p released, %d are still alive\n", | ||
159 | sk, atomic_read(&inet_sock_nr)); | ||
160 | #endif | ||
161 | } | 153 | } |
162 | 154 | ||
163 | /* | 155 | /* |
@@ -317,9 +309,7 @@ static int inet_create(struct socket *sock, int protocol) | |||
317 | inet->mc_index = 0; | 309 | inet->mc_index = 0; |
318 | inet->mc_list = NULL; | 310 | inet->mc_list = NULL; |
319 | 311 | ||
320 | #ifdef INET_REFCNT_DEBUG | 312 | sk_refcnt_debug_inc(sk); |
321 | atomic_inc(&inet_sock_nr); | ||
322 | #endif | ||
323 | 313 | ||
324 | if (inet->num) { | 314 | if (inet->num) { |
325 | /* It assumes that any protocol which allows | 315 | /* It assumes that any protocol which allows |
@@ -1205,7 +1195,3 @@ EXPORT_SYMBOL(inet_stream_ops); | |||
1205 | EXPORT_SYMBOL(inet_unregister_protosw); | 1195 | EXPORT_SYMBOL(inet_unregister_protosw); |
1206 | EXPORT_SYMBOL(net_statistics); | 1196 | EXPORT_SYMBOL(net_statistics); |
1207 | EXPORT_SYMBOL(sysctl_ip_nonlocal_bind); | 1197 | EXPORT_SYMBOL(sysctl_ip_nonlocal_bind); |
1208 | |||
1209 | #ifdef INET_REFCNT_DEBUG | ||
1210 | EXPORT_SYMBOL(inet_sock_nr); | ||
1211 | #endif | ||
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 42a2e2ccd430..20159a3dafb3 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -1580,12 +1580,7 @@ void tcp_destroy_sock(struct sock *sk) | |||
1580 | 1580 | ||
1581 | xfrm_sk_free_policy(sk); | 1581 | xfrm_sk_free_policy(sk); |
1582 | 1582 | ||
1583 | #ifdef INET_REFCNT_DEBUG | 1583 | sk_refcnt_debug_release(sk); |
1584 | if (atomic_read(&sk->sk_refcnt) != 1) { | ||
1585 | printk(KERN_DEBUG "Destruction TCP %p delayed, c=%d\n", | ||
1586 | sk, atomic_read(&sk->sk_refcnt)); | ||
1587 | } | ||
1588 | #endif | ||
1589 | 1584 | ||
1590 | atomic_dec(&tcp_orphan_count); | 1585 | atomic_dec(&tcp_orphan_count); |
1591 | sock_put(sk); | 1586 | sock_put(sk); |
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index f42a284164b7..f8e288c8d693 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c | |||
@@ -84,7 +84,7 @@ static void tcp_timewait_kill(struct tcp_tw_bucket *tw) | |||
84 | tcp_bucket_destroy(tb); | 84 | tcp_bucket_destroy(tb); |
85 | spin_unlock(&bhead->lock); | 85 | spin_unlock(&bhead->lock); |
86 | 86 | ||
87 | #ifdef INET_REFCNT_DEBUG | 87 | #ifdef SOCK_REFCNT_DEBUG |
88 | if (atomic_read(&tw->tw_refcnt) != 1) { | 88 | if (atomic_read(&tw->tw_refcnt) != 1) { |
89 | printk(KERN_DEBUG "tw_bucket %p refcnt=%d\n", tw, | 89 | printk(KERN_DEBUG "tw_bucket %p refcnt=%d\n", tw, |
90 | atomic_read(&tw->tw_refcnt)); | 90 | atomic_read(&tw->tw_refcnt)); |
@@ -799,9 +799,21 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req, | |||
799 | newsk->sk_err = 0; | 799 | newsk->sk_err = 0; |
800 | newsk->sk_priority = 0; | 800 | newsk->sk_priority = 0; |
801 | atomic_set(&newsk->sk_refcnt, 2); | 801 | atomic_set(&newsk->sk_refcnt, 2); |
802 | #ifdef INET_REFCNT_DEBUG | 802 | |
803 | atomic_inc(&inet_sock_nr); | 803 | /* |
804 | #endif | 804 | * Increment the counter in the same struct proto as the master |
805 | * sock (sk_refcnt_debug_inc uses newsk->sk_prot->socks, that | ||
806 | * is the same as sk->sk_prot->socks, as this field was copied | ||
807 | * with memcpy), same rationale as the first comment in this | ||
808 | * function. | ||
809 | * | ||
810 | * This _changes_ the previous behaviour, where | ||
811 | * tcp_create_openreq_child always was incrementing the | ||
812 | * equivalent to tcp_prot->socks (inet_sock_nr), so this have | ||
813 | * to be taken into account in all callers. -acme | ||
814 | */ | ||
815 | sk_refcnt_debug_inc(newsk); | ||
816 | |||
805 | atomic_inc(&tcp_sockets_allocated); | 817 | atomic_inc(&tcp_sockets_allocated); |
806 | 818 | ||
807 | if (sock_flag(newsk, SOCK_KEEPOPEN)) | 819 | if (sock_flag(newsk, SOCK_KEEPOPEN)) |