uipc_syscalls.c (0b759971a2de7100c7362fe782abe24da316c547) uipc_syscalls.c (90ecfebd8287b0c59fe80050d3026f7e94db5a3b)
1/*
2 * Copyright (c) 1982, 1986, 1989, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * sendfile(2) and related extensions:
6 * Copyright (c) 1998, David Greenman. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 1618 unchanged lines hidden (view full) ---

1627#endif
1628 sa->sa_len = len;
1629 *namp = sa;
1630 }
1631 return (error);
1632}
1633
1634/*
1/*
2 * Copyright (c) 1982, 1986, 1989, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * sendfile(2) and related extensions:
6 * Copyright (c) 1998, David Greenman. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 1618 unchanged lines hidden (view full) ---

1627#endif
1628 sa->sa_len = len;
1629 *namp = sa;
1630 }
1631 return (error);
1632}
1633
1634/*
1635 * Detatch mapped page and release resources back to the system.
1636 */
1637void
1638sf_buf_mext(void *addr, void *args)
1639{
1640 vm_page_t m;
1641
1642 m = sf_buf_page(args);
1643 sf_buf_free(args);
1644 vm_page_lock_queues();
1645 vm_page_unwire(m, 0);
1646 /*
1647 * Check for the object going away on us. This can
1648 * happen since we don't hold a reference to it.
1649 * If so, we're responsible for freeing the page.
1650 */
1651 if (m->wire_count == 0 && m->object == NULL)
1652 vm_page_free(m);
1653 vm_page_unlock_queues();
1654}
1655
1656/*
1635 * sendfile(2)
1636 *
1637 * MPSAFE
1638 *
1639 * int sendfile(int fd, int s, off_t offset, size_t nbytes,
1640 * struct sf_hdtr *hdtr, off_t *sbytes, int flags)
1641 *
1642 * Send a file specified by 'fd' and starting at 'offset' to a socket

--- 269 unchanged lines hidden (view full) ---

1912 * Get an mbuf header and set it up as having external storage.
1913 */
1914 if (m_header)
1915 MGET(m, M_TRYWAIT, MT_DATA);
1916 else
1917 MGETHDR(m, M_TRYWAIT, MT_DATA);
1918 if (m == NULL) {
1919 error = ENOBUFS;
1657 * sendfile(2)
1658 *
1659 * MPSAFE
1660 *
1661 * int sendfile(int fd, int s, off_t offset, size_t nbytes,
1662 * struct sf_hdtr *hdtr, off_t *sbytes, int flags)
1663 *
1664 * Send a file specified by 'fd' and starting at 'offset' to a socket

--- 269 unchanged lines hidden (view full) ---

1934 * Get an mbuf header and set it up as having external storage.
1935 */
1936 if (m_header)
1937 MGET(m, M_TRYWAIT, MT_DATA);
1938 else
1939 MGETHDR(m, M_TRYWAIT, MT_DATA);
1940 if (m == NULL) {
1941 error = ENOBUFS;
1920 sf_buf_free((void *)sf_buf_kva(sf), sf);
1942 sf_buf_mext((void *)sf_buf_kva(sf), sf);
1921 sbunlock(&so->so_snd);
1922 goto done;
1923 }
1924 /*
1925 * Setup external storage for mbuf.
1926 */
1943 sbunlock(&so->so_snd);
1944 goto done;
1945 }
1946 /*
1947 * Setup external storage for mbuf.
1948 */
1927 MEXTADD(m, sf_buf_kva(sf), PAGE_SIZE, sf_buf_free, sf, M_RDONLY,
1949 MEXTADD(m, sf_buf_kva(sf), PAGE_SIZE, sf_buf_mext, sf, M_RDONLY,
1928 EXT_SFBUF);
1929 m->m_data = (char *)sf_buf_kva(sf) + pgoff;
1930 m->m_pkthdr.len = m->m_len = xfsize;
1931
1932 if (m_header) {
1933 m_cat(m_header, m);
1934 m = m_header;
1935 m_header = NULL;

--- 120 unchanged lines hidden ---
1950 EXT_SFBUF);
1951 m->m_data = (char *)sf_buf_kva(sf) + pgoff;
1952 m->m_pkthdr.len = m->m_len = xfsize;
1953
1954 if (m_header) {
1955 m_cat(m_header, m);
1956 m = m_header;
1957 m_header = NULL;

--- 120 unchanged lines hidden ---