Author: glebius
Date: Thu Jan 16 13:45:41 2014
New Revision: 260719
URL: http://svnweb.freebsd.org/changeset/base/260719

Log:
  Simplify wait/nowait code, eventually killing last remnant of
  historical mbuf(9) allocator flag.
  
  Sponsored by: Nginx, Inc.

Modified:
  head/sys/kern/uipc_socket.c
  head/sys/sys/mbuf.h

Modified: head/sys/kern/uipc_socket.c
==============================================================================
--- head/sys/kern/uipc_socket.c Thu Jan 16 13:44:47 2014        (r260718)
+++ head/sys/kern/uipc_socket.c Thu Jan 16 13:45:41 2014        (r260719)
@@ -1723,28 +1723,27 @@ dontblock:
                                moff += len;
                        else {
                                if (mp != NULL) {
-                                       int copy_flag;
-
-                                       if (flags & MSG_DONTWAIT)
-                                               copy_flag = M_NOWAIT;
-                                       else
-                                               copy_flag = M_WAIT;
-                                       if (copy_flag == M_WAITOK)
+                                       if (flags & MSG_DONTWAIT) {
+                                               *mp = m_copym(m, 0, len,
+                                                   M_NOWAIT);
+                                               if (*mp == NULL) {
+                                                       /*
+                                                        * m_copym() couldn't
+                                                        * allocate an mbuf.
+                                                        * Adjust uio_resid back
+                                                        * (it was adjusted
+                                                        * down by len bytes,
+                                                        * which we didn't end
+                                                        * up "copying" over).
+                                                        */
+                                                       uio->uio_resid += len;
+                                                       break;
+                                               }
+                                       } else {
                                                SOCKBUF_UNLOCK(&so->so_rcv);
-                                       *mp = m_copym(m, 0, len, copy_flag);
-                                       if (copy_flag == M_WAITOK)
+                                               *mp = m_copym(m, 0, len,
+                                                   M_WAITOK);
                                                SOCKBUF_LOCK(&so->so_rcv);
-                                       if (*mp == NULL) {
-                                               /*
-                                                * m_copym() couldn't
-                                                * allocate an mbuf.  Adjust
-                                                * uio_resid back (it was
-                                                * adjusted down by len
-                                                * bytes, which we didn't end
-                                                * up "copying" over).
-                                                */
-                                               uio->uio_resid += len;
-                                               break;
                                        }
                                }
                                m->m_data += len;

Modified: head/sys/sys/mbuf.h
==============================================================================
--- head/sys/sys/mbuf.h Thu Jan 16 13:44:47 2014        (r260718)
+++ head/sys/sys/mbuf.h Thu Jan 16 13:45:41 2014        (r260719)
@@ -466,14 +466,6 @@ struct mbuf {
                                   a non-initialized mbuf */
 
 /*
- * Compatibility with historic mbuf allocator.
- */
-#define        MBTOM(how)      (how)
-#define        M_DONTWAIT      M_NOWAIT
-#define        M_TRYWAIT       M_WAITOK
-#define        M_WAIT          M_WAITOK
-
-/*
  * String names of mbuf-related UMA(9) and malloc(9) types.  Exposed to
  * !_KERNEL so that monitoring tools can look up the zones with
  * libmemstat(3).
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to