|
|
| version 1.34, 2004/05/09 00:32:41 | version 1.35, 2004/05/13 17:40:15 |
|---|---|
| Line 1422 done: | Line 1422 done: |
| } | } |
| int | int |
| kern_sendfile(struct vnode *vp, int s, off_t offset, size_t nbytes, | kern_sendfile(struct vnode *vp, int sfd, off_t offset, size_t nbytes, |
| struct mbuf *mheader, off_t *sbytes, int flags) | struct mbuf *mheader, off_t *sbytes, int flags) |
| { | { |
| struct thread *td = curthread; | struct thread *td = curthread; |
| Line 1436 kern_sendfile(struct vnode *vp, int s, o | Line 1436 kern_sendfile(struct vnode *vp, int s, o |
| off_t off, xfsize; | off_t off, xfsize; |
| off_t hbytes = 0; | off_t hbytes = 0; |
| int error = 0; | int error = 0; |
| int s; | |
| if (vp->v_type != VREG || VOP_GETVOBJECT(vp, &obj) != 0) { | if (vp->v_type != VREG || VOP_GETVOBJECT(vp, &obj) != 0) { |
| error = EINVAL; | error = EINVAL; |
| goto done; | goto done; |
| } | } |
| error = holdsock(p->p_fd, s, &fp); | error = holdsock(p->p_fd, sfd, &fp); |
| if (error) | if (error) |
| goto done; | goto done; |
| so = (struct socket *)fp->f_data; | so = (struct socket *)fp->f_data; |
| Line 1505 retry_lookup: | Line 1506 retry_lookup: |
| /* | /* |
| * Attempt to look up the page. | * Attempt to look up the page. |
| * | * |
| * Allocate if not found | * Allocate if not found, wait and loop if busy, then |
| * | * wire the page. splvm() protection is required to |
| * Wait and loop if busy. | * maintain the object association (an interrupt can |
| * free the page) through to the vm_page_wire() call. | |
| */ | */ |
| s = splvm(); | |
| pg = vm_page_lookup(obj, pindex); | pg = vm_page_lookup(obj, pindex); |
| if (pg == NULL) { | if (pg == NULL) { |
| pg = vm_page_alloc(obj, pindex, VM_ALLOC_NORMAL); | pg = vm_page_alloc(obj, pindex, VM_ALLOC_NORMAL); |
| if (pg == NULL) { | if (pg == NULL) { |
| VM_WAIT; | VM_WAIT; |
| splx(s); | |
| goto retry_lookup; | goto retry_lookup; |
| } | } |
| vm_page_wakeup(pg); | vm_page_wakeup(pg); |
| } else if (vm_page_sleep_busy(pg, TRUE, "sfpbsy")) { | } else if (vm_page_sleep_busy(pg, TRUE, "sfpbsy")) { |
| splx(s); | |
| goto retry_lookup; | goto retry_lookup; |
| } | } |
| /* | |
| * Wire the page so it does not get ripped out from under | |
| * us. | |
| */ | |
| vm_page_wire(pg); | vm_page_wire(pg); |
| splx(s); | |
| /* | /* |
| * If page is not valid for what we need, initiate I/O | * If page is not valid for what we need, initiate I/O |