* Disassociate the socket from it's protocol specific * partner. If it's attached to a node's private data structure, * then unlink from that too. If we were the last socket attached to it, * then shut down the entire node. Shared code for control and data sockets. */
| 628 | * then shut down the entire node. Shared code for control and data sockets. |
| 629 | */ |
| 630 | static void |
| 631 | ng_detach_common(struct ngpcb *pcbp, int which) |
| 632 | { |
| 633 | struct ngsock *priv = pcbp->sockdata; |
| 634 | |
| 635 | if (priv != NULL) { |
| 636 | mtx_lock(&priv->mtx); |
| 637 | |
| 638 | switch (which) { |
| 639 | case NG_CONTROL: |
| 640 | priv->ctlsock = NULL; |
| 641 | break; |
| 642 | case NG_DATA: |
| 643 | priv->datasock = NULL; |
| 644 | break; |
| 645 | default: |
| 646 | panic("%s", __func__); |
| 647 | } |
| 648 | pcbp->sockdata = NULL; |
| 649 | pcbp->node_id = 0; |
| 650 | |
| 651 | ng_socket_free_priv(priv); |
| 652 | } |
| 653 | |
| 654 | pcbp->ng_socket->so_pcb = NULL; |
| 655 | mtx_lock(&ngsocketlist_mtx); |
| 656 | LIST_REMOVE(pcbp, socks); |
| 657 | mtx_unlock(&ngsocketlist_mtx); |
| 658 | free(pcbp, M_PCB); |
| 659 | } |
| 660 | |
| 661 | /* |
| 662 | * Remove a reference from node private data. |
no test coverage detected