Deleted Added
full compact
kern_sendfile.c (137340) kern_sendfile.c (137355)
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

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

28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94
33 */
34
35#include <sys/cdefs.h>
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

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

28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94
33 */
34
35#include <sys/cdefs.h>
36__FBSDID("$FreeBSD: head/sys/kern/uipc_syscalls.c 137340 2004-11-07 16:09:56Z phk $");
36__FBSDID("$FreeBSD: head/sys/kern/uipc_syscalls.c 137355 2004-11-07 22:16:07Z phk $");
37
38#include "opt_compat.h"
39#include "opt_ktrace.h"
40#include "opt_mac.h"
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/kernel.h>

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

162 error = falloc(td, &fp, &fd);
163 if (error)
164 return (error);
165 /* An extra reference on `fp' has been held for us by falloc(). */
166 NET_LOCK_GIANT();
167 error = socreate(uap->domain, &so, uap->type, uap->protocol,
168 td->td_ucred, td);
169 NET_UNLOCK_GIANT();
37
38#include "opt_compat.h"
39#include "opt_ktrace.h"
40#include "opt_mac.h"
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/kernel.h>

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

162 error = falloc(td, &fp, &fd);
163 if (error)
164 return (error);
165 /* An extra reference on `fp' has been held for us by falloc(). */
166 NET_LOCK_GIANT();
167 error = socreate(uap->domain, &so, uap->type, uap->protocol,
168 td->td_ucred, td);
169 NET_UNLOCK_GIANT();
170 FILEDESC_LOCK(fdp);
171 if (error) {
170 if (error) {
172 if (fdp->fd_ofiles[fd] == fp) {
173 fdp->fd_ofiles[fd] = NULL;
174 fdunused(fdp, fd);
175 FILEDESC_UNLOCK(fdp);
176 fdrop(fp, td);
177 } else {
178 FILEDESC_UNLOCK(fdp);
179 }
171 fdclose(fdp, fp, fd, td);
180 } else {
172 } else {
173 FILEDESC_LOCK(fdp);
181 fp->f_data = so; /* already has ref count */
182 fp->f_flag = FREAD|FWRITE;
183 fp->f_ops = &socketops;
184 fp->f_type = DTYPE_SOCKET;
185 FILEDESC_UNLOCK(fdp);
186 td->td_retval[0] = fd;
187 }
188 fdrop(fp, td);

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

430noconnection:
431 if (sa)
432 FREE(sa, M_SONAME);
433
434 /*
435 * close the new descriptor, assuming someone hasn't ripped it
436 * out from under us.
437 */
174 fp->f_data = so; /* already has ref count */
175 fp->f_flag = FREAD|FWRITE;
176 fp->f_ops = &socketops;
177 fp->f_type = DTYPE_SOCKET;
178 FILEDESC_UNLOCK(fdp);
179 td->td_retval[0] = fd;
180 }
181 fdrop(fp, td);

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

423noconnection:
424 if (sa)
425 FREE(sa, M_SONAME);
426
427 /*
428 * close the new descriptor, assuming someone hasn't ripped it
429 * out from under us.
430 */
438 if (error) {
439 FILEDESC_LOCK(fdp);
440 if (fdp->fd_ofiles[fd] == nfp) {
441 fdp->fd_ofiles[fd] = NULL;
442 fdunused(fdp, fd);
443 FILEDESC_UNLOCK(fdp);
444 fdrop(nfp, td);
445 } else {
446 FILEDESC_UNLOCK(fdp);
447 }
448 }
431 if (error)
432 fdclose(fdp, nfp, fd, td);
449
450 /*
451 * Release explicitly held references before returning.
452 */
453done:
454 if (nfp != NULL)
455 fdrop(nfp, td);
456 fputsock(head);

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

632 fp2->f_ops = &socketops;
633 fp2->f_type = DTYPE_SOCKET;
634 FILE_UNLOCK(fp2);
635 error = copyout(sv, uap->rsv, 2 * sizeof (int));
636 fdrop(fp1, td);
637 fdrop(fp2, td);
638 goto done2;
639free4:
433
434 /*
435 * Release explicitly held references before returning.
436 */
437done:
438 if (nfp != NULL)
439 fdrop(nfp, td);
440 fputsock(head);

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

616 fp2->f_ops = &socketops;
617 fp2->f_type = DTYPE_SOCKET;
618 FILE_UNLOCK(fp2);
619 error = copyout(sv, uap->rsv, 2 * sizeof (int));
620 fdrop(fp1, td);
621 fdrop(fp2, td);
622 goto done2;
623free4:
640 FILEDESC_LOCK(fdp);
641 if (fdp->fd_ofiles[sv[1]] == fp2) {
642 fdp->fd_ofiles[sv[1]] = NULL;
643 fdunused(fdp, sv[1]);
644 FILEDESC_UNLOCK(fdp);
645 fdrop(fp2, td);
646 } else {
647 FILEDESC_UNLOCK(fdp);
648 }
624 fdclose(fdp, fp2, sv[1], td);
649 fdrop(fp2, td);
650free3:
625 fdrop(fp2, td);
626free3:
651 FILEDESC_LOCK(fdp);
652 if (fdp->fd_ofiles[sv[0]] == fp1) {
653 fdp->fd_ofiles[sv[0]] = NULL;
654 fdunused(fdp, sv[0]);
655 FILEDESC_UNLOCK(fdp);
656 fdrop(fp1, td);
657 } else {
658 FILEDESC_UNLOCK(fdp);
659 }
627 fdclose(fdp, fp1, sv[0], td);
660 fdrop(fp1, td);
661free2:
662 (void)soclose(so2);
663free1:
664 (void)soclose(so1);
665done2:
666 NET_UNLOCK_GIANT();
667 return (error);

--- 1486 unchanged lines hidden ---
628 fdrop(fp1, td);
629free2:
630 (void)soclose(so2);
631free1:
632 (void)soclose(so1);
633done2:
634 NET_UNLOCK_GIANT();
635 return (error);

--- 1486 unchanged lines hidden ---