]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - net/sctp/socket.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[linux.git] / net / sctp / socket.c
index 4583fa914e62aedaf2ef29c5cf668f0caee4eade..e4e892cc5644811b876d5a1cbd25e4fe3ef30136 100644 (file)
@@ -1913,7 +1913,10 @@ static int sctp_sendmsg_to_asoc(struct sctp_association *asoc,
        if (sctp_wspace(asoc) < (int)msg_len)
                sctp_prsctp_prune(asoc, sinfo, msg_len - sctp_wspace(asoc));
 
-       if (sctp_wspace(asoc) <= 0) {
+       if (sk_under_memory_pressure(sk))
+               sk_mem_reclaim(sk);
+
+       if (sctp_wspace(asoc) <= 0 || !sk_wmem_schedule(sk, msg_len)) {
                timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
                err = sctp_wait_for_sndbuf(asoc, &timeo, msg_len);
                if (err)
@@ -8931,7 +8934,10 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc, long *timeo_p,
                        goto do_error;
                if (signal_pending(current))
                        goto do_interrupted;
-               if ((int)msg_len <= sctp_wspace(asoc))
+               if (sk_under_memory_pressure(sk))
+                       sk_mem_reclaim(sk);
+               if ((int)msg_len <= sctp_wspace(asoc) &&
+                   sk_wmem_schedule(sk, msg_len))
                        break;
 
                /* Let another process have a go.  Since we are going