patch-2.1.106 linux/net/core/sock.c
Next file: linux/net/ipv4/fib_frontend.c
Previous file: linux/net/core/profile.c
Back to the patch index
Back to the overall index
- Lines: 83
- Date:
Sat Jun 13 11:45:10 1998
- Orig file:
v2.1.105/linux/net/core/sock.c
- Orig date:
Thu May 7 22:51:55 1998
diff -u --recursive --new-file v2.1.105/linux/net/core/sock.c linux/net/core/sock.c
@@ -206,18 +206,14 @@
sk->broadcast=valbool;
break;
case SO_SNDBUF:
- /*
- * The spec isnt clear if ENOBUFS or EINVAL
- * is best
- */
-
- /* printk(KERN_DEBUG "setting SO_SNDBUF %d\n", val); */
+ /* Don't error on this BSD doesn't and if you think
+ about it this is right. Otherwise apps have to
+ play 'guess the biggest size' games. RCVBUF/SNDBUF
+ are treated in BSD as hints */
+
if (val > sysctl_wmem_max)
- return -EINVAL;
+ return 0;
- /* FIXME: the tcp code should be made to work even
- * with small sndbuf values.
- */
sk->sndbuf = max(val*2,2048);
/*
@@ -228,10 +224,13 @@
break;
case SO_RCVBUF:
- /* printk(KERN_DEBUG "setting SO_RCVBUF %d\n", val); */
-
+ /* Don't error on this BSD doesn't and if you think
+ about it this is right. Otherwise apps have to
+ play 'guess the biggest size' games. RCVBUF/SNDBUF
+ are treated in BSD as hints */
+
if (val > sysctl_rmem_max)
- return -EINVAL;
+ return 0;
/* FIXME: is this lower bound the right one? */
sk->rcvbuf = max(val*2,256);
@@ -480,8 +479,8 @@
{
struct sock *sk = kmem_cache_alloc(sk_cachep, priority);
- if(sk && zero_it) {
- memset(sk, 0, sizeof(struct sock));
+ if(sk) {
+ if (zero_it) memset(sk, 0, sizeof(struct sock));
sk->family = family;
}
@@ -564,15 +563,18 @@
void *sock_kmalloc(struct sock *sk, int size, int priority)
{
- void *mem = NULL;
if (atomic_read(&sk->omem_alloc)+size < sysctl_optmem_max) {
+ void *mem;
/* First do the add, to avoid the race if kmalloc
* might sleep.
*/
atomic_add(size, &sk->omem_alloc);
mem = kmalloc(size, priority);
+ if (mem)
+ return mem;
+ atomic_sub(size, &sk->omem_alloc);
}
- return mem;
+ return NULL;
}
void sock_kfree_s(struct sock *sk, void *mem, int size)
@@ -880,7 +882,7 @@
unsigned int sock_no_poll(struct file * file, struct socket *sock, poll_table *pt)
{
- return -EOPNOTSUPP;
+ return 0;
}
int sock_no_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov