--- linux-2.4.19-smp/net/ipv4/ip_output.c.orig Mon May 13 23:34:37 2002 +++ linux-2.4.19-smp/net/ipv4/ip_output.c Fri Jun 28 10:07:16 2002 @@ -508,6 +508,16 @@ goto out; /* + * Rough estimate of socket memory useage. Doesn't take into account + * the overhead due to fragment headers, alignment... + */ + if (flags&MSG_DONTWAIT && sk->sndbuf - atomic_read(&sk->wmem_alloc) < (int)length) { + set_bit(SOCK_ASYNC_NOSPACE, &sk->socket->flags); + set_bit(SOCK_NOSPACE, &sk->socket->flags); + return -EAGAIN; + } + + /* * Begin outputting the bytes. */ @@ -521,7 +531,11 @@ * Get the memory we require with some space left for alignment. */ - skb = sock_alloc_send_skb(sk, fraglen+hh_len+15, flags&MSG_DONTWAIT, &err); + if (flags&MSG_DONTWAIT) { + err = -ENOBUFS; + skb = sock_wmalloc(sk, fraglen+hh_len+15, 1, sk->allocation); + } else + skb = sock_alloc_send_skb(sk, fraglen+hh_len+15, 0, &err); if (skb == NULL) goto error;