patch-2.1.43 linux/net/core/sock.c

Next file: linux/net/core/sysctl_net_core.c
Previous file: linux/net/core/dev.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.42/linux/net/core/sock.c linux/net/core/sock.c
@@ -71,6 +71,8 @@
  *		Alan Cox	: 	Generic socket allocation to make hooks
  *					easier (suggested by Craig Metz).
  *		Michael Pall	:	SO_ERROR returns positive errno again
+ *             Steve Whitehouse:       Added default destructor to free
+ *                                     protocol private data.
  *
  * To Fix:
  *
@@ -124,6 +126,8 @@
 __u32 sysctl_wmem_default = SK_WMEM_MAX;
 __u32 sysctl_rmem_default = SK_RMEM_MAX;
 
+int sysctl_core_destroy_delay = SOCK_DESTROY_TIME;
+
 /*
  *	This is meant for all protocols to use and covers goings on
  *	at the socket level. Everything here is generic.
@@ -465,6 +469,9 @@
 
 void sk_free(struct sock *sk)
 {
+	if (sk->destruct)
+		sk->destruct(sk);
+
 	kmem_cache_free(sk_cachep, sk);
 }
 
@@ -787,7 +794,7 @@
 		 *	Someone is using our buffers still.. defer
 		 */
 		init_timer(&sk->timer);
-		sk->timer.expires=jiffies+10*HZ;
+		sk->timer.expires=jiffies+sysctl_core_destroy_delay;
 		sk->timer.function=sklist_destroy_timer;
 		sk->timer.data = (unsigned long)sk;
 		add_timer(&sk->timer);
@@ -874,6 +881,12 @@
 	}
 }
 
+void sock_def_destruct(struct sock *sk)
+{
+	if (sk->protinfo.destruct_hook)
+		kfree(sk->protinfo.destruct_hook);
+}
+
 void sock_init_data(struct socket *sock, struct sock *sk)
 {
 	skb_queue_head_init(&sk->receive_queue);
@@ -901,6 +914,7 @@
 	sk->data_ready		=	sock_def_callback2;
 	sk->write_space		=	sock_def_callback3;
 	sk->error_report	=	sock_def_callback1;
+	sk->destruct            =       sock_def_destruct;
 
 	sk->peercred.pid 	=	0;
 	sk->peercred.uid	=	-1;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov