uipc_usrreq.c (302408) | uipc_usrreq.c (305159) |
---|---|
1/*- 2 * Copyright (c) 1982, 1986, 1989, 1991, 1993 3 * The Regents of the University of California. 4 * Copyright (c) 2004-2009 Robert N. M. Watson 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 42 unchanged lines hidden (view full) --- 51 * 52 * TODO: 53 * RDM 54 * rethink name space problems 55 * need a proper out-of-band 56 */ 57 58#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1982, 1986, 1989, 1991, 1993 3 * The Regents of the University of California. 4 * Copyright (c) 2004-2009 Robert N. M. Watson 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 42 unchanged lines hidden (view full) --- 51 * 52 * TODO: 53 * RDM 54 * rethink name space problems 55 * need a proper out-of-band 56 */ 57 58#include <sys/cdefs.h> |
59__FBSDID("$FreeBSD: stable/11/sys/kern/uipc_usrreq.c 298310 2016-04-19 23:48:27Z pfg $"); | 59__FBSDID("$FreeBSD: stable/11/sys/kern/uipc_usrreq.c 305159 2016-08-31 21:35:12Z markj $"); |
60 61#include "opt_ddb.h" 62 63#include <sys/param.h> 64#include <sys/capsicum.h> 65#include <sys/domain.h> 66#include <sys/fcntl.h> 67#include <sys/malloc.h> /* XXX must be before <sys/file.h> */ --- 357 unchanged lines hidden (view full) --- 425 unp = uma_zalloc(unp_zone, M_NOWAIT | M_ZERO); 426 if (unp == NULL) 427 return (ENOBUFS); 428 LIST_INIT(&unp->unp_refs); 429 UNP_PCB_LOCK_INIT(unp); 430 unp->unp_socket = so; 431 so->so_pcb = unp; 432 unp->unp_refcount = 1; | 60 61#include "opt_ddb.h" 62 63#include <sys/param.h> 64#include <sys/capsicum.h> 65#include <sys/domain.h> 66#include <sys/fcntl.h> 67#include <sys/malloc.h> /* XXX must be before <sys/file.h> */ --- 357 unchanged lines hidden (view full) --- 425 unp = uma_zalloc(unp_zone, M_NOWAIT | M_ZERO); 426 if (unp == NULL) 427 return (ENOBUFS); 428 LIST_INIT(&unp->unp_refs); 429 UNP_PCB_LOCK_INIT(unp); 430 unp->unp_socket = so; 431 so->so_pcb = unp; 432 unp->unp_refcount = 1; |
433 if (so->so_head != NULL) 434 unp->unp_flags |= UNP_NASCENT; |
|
433 434 UNP_LIST_LOCK(); 435 unp->unp_gencnt = ++unp_gencnt; 436 unp_count++; 437 switch (so->so_type) { 438 case SOCK_STREAM: 439 LIST_INSERT_HEAD(&unp_shead, unp, unp_link); 440 break; --- 206 unchanged lines hidden (view full) --- 647 struct unpcb *unp, *unp2; 648 struct sockaddr_un *saved_unp_addr; 649 struct vnode *vp; 650 int freeunp, local_unp_rights; 651 652 unp = sotounpcb(so); 653 KASSERT(unp != NULL, ("uipc_detach: unp == NULL")); 654 | 435 436 UNP_LIST_LOCK(); 437 unp->unp_gencnt = ++unp_gencnt; 438 unp_count++; 439 switch (so->so_type) { 440 case SOCK_STREAM: 441 LIST_INSERT_HEAD(&unp_shead, unp, unp_link); 442 break; --- 206 unchanged lines hidden (view full) --- 649 struct unpcb *unp, *unp2; 650 struct sockaddr_un *saved_unp_addr; 651 struct vnode *vp; 652 int freeunp, local_unp_rights; 653 654 unp = sotounpcb(so); 655 KASSERT(unp != NULL, ("uipc_detach: unp == NULL")); 656 |
655 UNP_LINK_WLOCK(); | 657 vp = NULL; 658 local_unp_rights = 0; 659 |
656 UNP_LIST_LOCK(); | 660 UNP_LIST_LOCK(); |
657 UNP_PCB_LOCK(unp); | |
658 LIST_REMOVE(unp, unp_link); 659 unp->unp_gencnt = ++unp_gencnt; 660 --unp_count; 661 UNP_LIST_UNLOCK(); 662 | 661 LIST_REMOVE(unp, unp_link); 662 unp->unp_gencnt = ++unp_gencnt; 663 --unp_count; 664 UNP_LIST_UNLOCK(); 665 |
666 if ((unp->unp_flags & UNP_NASCENT) != 0) { 667 UNP_PCB_LOCK(unp); 668 goto teardown; 669 } 670 UNP_LINK_WLOCK(); 671 UNP_PCB_LOCK(unp); 672 |
|
663 /* 664 * XXXRW: Should assert vp->v_socket == so. 665 */ 666 if ((vp = unp->unp_vnode) != NULL) { 667 VOP_UNP_DETACH(vp); 668 unp->unp_vnode = NULL; 669 } 670 unp2 = unp->unp_conn; --- 11 unchanged lines hidden (view full) --- 682 struct unpcb *ref = LIST_FIRST(&unp->unp_refs); 683 684 UNP_PCB_LOCK(ref); 685 unp_drop(ref); 686 UNP_PCB_UNLOCK(ref); 687 } 688 local_unp_rights = unp_rights; 689 UNP_LINK_WUNLOCK(); | 673 /* 674 * XXXRW: Should assert vp->v_socket == so. 675 */ 676 if ((vp = unp->unp_vnode) != NULL) { 677 VOP_UNP_DETACH(vp); 678 unp->unp_vnode = NULL; 679 } 680 unp2 = unp->unp_conn; --- 11 unchanged lines hidden (view full) --- 692 struct unpcb *ref = LIST_FIRST(&unp->unp_refs); 693 694 UNP_PCB_LOCK(ref); 695 unp_drop(ref); 696 UNP_PCB_UNLOCK(ref); 697 } 698 local_unp_rights = unp_rights; 699 UNP_LINK_WUNLOCK(); |
700teardown: |
|
690 unp->unp_socket->so_pcb = NULL; 691 saved_unp_addr = unp->unp_addr; 692 unp->unp_addr = NULL; 693 unp->unp_refcount--; 694 freeunp = (unp->unp_refcount == 0); 695 if (saved_unp_addr != NULL) 696 free(saved_unp_addr, M_SONAME); 697 if (freeunp) { --- 770 unchanged lines hidden (view full) --- 1468 KASSERT(unp2 != NULL, ("unp_connect2: unp2 == NULL")); 1469 1470 UNP_LINK_WLOCK_ASSERT(); 1471 UNP_PCB_LOCK_ASSERT(unp); 1472 UNP_PCB_LOCK_ASSERT(unp2); 1473 1474 if (so2->so_type != so->so_type) 1475 return (EPROTOTYPE); | 701 unp->unp_socket->so_pcb = NULL; 702 saved_unp_addr = unp->unp_addr; 703 unp->unp_addr = NULL; 704 unp->unp_refcount--; 705 freeunp = (unp->unp_refcount == 0); 706 if (saved_unp_addr != NULL) 707 free(saved_unp_addr, M_SONAME); 708 if (freeunp) { --- 770 unchanged lines hidden (view full) --- 1479 KASSERT(unp2 != NULL, ("unp_connect2: unp2 == NULL")); 1480 1481 UNP_LINK_WLOCK_ASSERT(); 1482 UNP_PCB_LOCK_ASSERT(unp); 1483 UNP_PCB_LOCK_ASSERT(unp2); 1484 1485 if (so2->so_type != so->so_type) 1486 return (EPROTOTYPE); |
1487 unp2->unp_flags &= ~UNP_NASCENT; |
|
1476 unp->unp_conn = unp2; 1477 1478 switch (so->so_type) { 1479 case SOCK_DGRAM: 1480 LIST_INSERT_HEAD(&unp2->unp_refs, unp, unp_reflink); 1481 soisconnected(so); 1482 break; 1483 --- 1076 unchanged lines hidden --- | 1488 unp->unp_conn = unp2; 1489 1490 switch (so->so_type) { 1491 case SOCK_DGRAM: 1492 LIST_INSERT_HEAD(&unp2->unp_refs, unp, unp_reflink); 1493 soisconnected(so); 1494 break; 1495 --- 1076 unchanged lines hidden --- |