From 3d1592ef32c968de781325bc0f2369566a13a762 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Sat, 20 Sep 2014 16:43:14 +0000 Subject: [PATCH] Use callout(9) instead of timeout(9). Reviewed by: emax --- sys/netgraph/bluetooth/include/ng_btsocket_l2cap.h | 2 +- sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h | 2 +- sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c | 13 +++++-------- sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c | 12 +++++------- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/sys/netgraph/bluetooth/include/ng_btsocket_l2cap.h b/sys/netgraph/bluetooth/include/ng_btsocket_l2cap.h index deea5b3db0df..493ea42146a6 100644 --- a/sys/netgraph/bluetooth/include/ng_btsocket_l2cap.h +++ b/sys/netgraph/bluetooth/include/ng_btsocket_l2cap.h @@ -162,7 +162,7 @@ struct ng_btsocket_l2cap_pcb { u_int16_t flush_timo; /* flush timeout */ u_int16_t link_timo; /* link timeout */ - struct callout_handle timo; /* timeout */ + struct callout timo; /* timeout */ u_int32_t token; /* message token */ ng_btsocket_l2cap_rtentry_p rt; /* routing info */ diff --git a/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h b/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h index 4aaa658bd9ee..fdc1d00cbe6e 100644 --- a/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h +++ b/sys/netgraph/bluetooth/include/ng_btsocket_rfcomm.h @@ -296,7 +296,7 @@ struct ng_btsocket_rfcomm_pcb { int16_t tx_cred; /* TX credits */ struct mtx pcb_mtx; /* PCB lock */ - struct callout_handle timo; /* timeout */ + struct callout timo; /* timeout */ LIST_ENTRY(ng_btsocket_rfcomm_pcb) session_next;/* link to next */ LIST_ENTRY(ng_btsocket_rfcomm_pcb) next; /* link to next */ diff --git a/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c b/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c index af2ce1a5f468..bab8bbbbdd85 100644 --- a/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c +++ b/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c @@ -1967,8 +1967,6 @@ ng_btsocket_l2cap_attach(struct socket *so, int proto, struct thread *td) pcb->flush_timo = NG_L2CAP_FLUSH_TIMO_DEFAULT; pcb->link_timo = NG_L2CAP_LINK_TIMO_DEFAULT; - callout_handle_init(&pcb->timo); - /* * XXX Mark PCB mutex as DUPOK to prevent "duplicated lock of * the same type" message. When accepting new L2CAP connection @@ -1978,6 +1976,7 @@ ng_btsocket_l2cap_attach(struct socket *so, int proto, struct thread *td) mtx_init(&pcb->pcb_mtx, "btsocks_l2cap_pcb_mtx", NULL, MTX_DEF|MTX_DUPOK); + callout_init_mtx(&pcb->timo, &pcb->pcb_mtx, 0); /* * Add the PCB to the list @@ -2664,8 +2663,8 @@ ng_btsocket_l2cap_timeout(ng_btsocket_l2cap_pcb_p pcb) if (!(pcb->flags & NG_BTSOCKET_L2CAP_TIMO)) { pcb->flags |= NG_BTSOCKET_L2CAP_TIMO; - pcb->timo = timeout(ng_btsocket_l2cap_process_timeout, pcb, - bluetooth_l2cap_ertx_timeout()); + callout_reset(&pcb->timo, bluetooth_l2cap_ertx_timeout(), + ng_btsocket_l2cap_process_timeout, pcb); } else KASSERT(0, ("%s: Duplicated socket timeout?!\n", __func__)); @@ -2681,7 +2680,7 @@ ng_btsocket_l2cap_untimeout(ng_btsocket_l2cap_pcb_p pcb) mtx_assert(&pcb->pcb_mtx, MA_OWNED); if (pcb->flags & NG_BTSOCKET_L2CAP_TIMO) { - untimeout(ng_btsocket_l2cap_process_timeout, pcb, pcb->timo); + callout_stop(&pcb->timo); pcb->flags &= ~NG_BTSOCKET_L2CAP_TIMO; } else KASSERT(0, @@ -2697,7 +2696,7 @@ ng_btsocket_l2cap_process_timeout(void *xpcb) { ng_btsocket_l2cap_pcb_p pcb = (ng_btsocket_l2cap_pcb_p) xpcb; - mtx_lock(&pcb->pcb_mtx); + mtx_assert(&pcb->pcb_mtx, MA_OWNED); pcb->flags &= ~NG_BTSOCKET_L2CAP_TIMO; pcb->so->so_error = ETIMEDOUT; @@ -2731,8 +2730,6 @@ ng_btsocket_l2cap_process_timeout(void *xpcb) "%s: Invalid socket state=%d\n", __func__, pcb->state); break; } - - mtx_unlock(&pcb->pcb_mtx); } /* ng_btsocket_l2cap_process_timeout */ /* diff --git a/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c b/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c index 215843cf94b6..cb3753d4bf04 100644 --- a/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c +++ b/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c @@ -434,7 +434,7 @@ ng_btsocket_rfcomm_attach(struct socket *so, int proto, struct thread *td) pcb->rx_cred = RFCOMM_DEFAULT_CREDITS; mtx_init(&pcb->pcb_mtx, "btsocks_rfcomm_pcb_mtx", NULL, MTX_DEF); - callout_handle_init(&pcb->timo); + callout_init_mtx(&pcb->timo, &pcb->pcb_mtx, 0); /* Add the PCB to the list */ mtx_lock(&ng_btsocket_rfcomm_sockets_mtx); @@ -3451,8 +3451,8 @@ ng_btsocket_rfcomm_timeout(ng_btsocket_rfcomm_pcb_p pcb) if (!(pcb->flags & NG_BTSOCKET_RFCOMM_DLC_TIMO)) { pcb->flags |= NG_BTSOCKET_RFCOMM_DLC_TIMO; pcb->flags &= ~NG_BTSOCKET_RFCOMM_DLC_TIMEDOUT; - pcb->timo = timeout(ng_btsocket_rfcomm_process_timeout, pcb, - ng_btsocket_rfcomm_timo * hz); + callout_reset(&pcb->timo, ng_btsocket_rfcomm_timo * hz, + ng_btsocket_rfcomm_process_timeout, pcb); } else panic("%s: Duplicated socket timeout?!\n", __func__); } /* ng_btsocket_rfcomm_timeout */ @@ -3467,7 +3467,7 @@ ng_btsocket_rfcomm_untimeout(ng_btsocket_rfcomm_pcb_p pcb) mtx_assert(&pcb->pcb_mtx, MA_OWNED); if (pcb->flags & NG_BTSOCKET_RFCOMM_DLC_TIMO) { - untimeout(ng_btsocket_rfcomm_process_timeout, pcb, pcb->timo); + callout_stop(&pcb->timo); pcb->flags &= ~NG_BTSOCKET_RFCOMM_DLC_TIMO; pcb->flags &= ~NG_BTSOCKET_RFCOMM_DLC_TIMEDOUT; } else @@ -3483,7 +3483,7 @@ ng_btsocket_rfcomm_process_timeout(void *xpcb) { ng_btsocket_rfcomm_pcb_p pcb = (ng_btsocket_rfcomm_pcb_p) xpcb; - mtx_lock(&pcb->pcb_mtx); + mtx_assert(&pcb->pcb_mtx, MA_OWNED); NG_BTSOCKET_RFCOMM_INFO( "%s: Timeout, so=%p, dlci=%d, state=%d, flags=%#x\n", @@ -3510,8 +3510,6 @@ ng_btsocket_rfcomm_process_timeout(void *xpcb) } ng_btsocket_rfcomm_task_wakeup(); - - mtx_unlock(&pcb->pcb_mtx); } /* ng_btsocket_rfcomm_process_timeout */ /*