- if (tp->t_timer[TCPT_2MSL] == 0)
- tp = tcp_timers(tp, TCPT_2MSL);
+ if (tp->t_timer[TCPT_2MSL] == 0)
+ tp = tcp_timers(tp, TCPT_2MSL); /* tp can be returned null if tcp_close is called */
+twunlock:
+ tcp_unlock(inp->inp_socket, 1, 0);
+ }
+
+ if (lck_rw_lock_shared_to_exclusive(pcbinfo->mtx) != 0)
+ lck_rw_lock_exclusive(pcbinfo->mtx); /* Upgrade failed, lost lock no take it again exclusive */
+
+
+ for (inp = tcb.lh_first; inp != NULL; inp = inpnxt) {
+ inpnxt = inp->inp_list.le_next;
+ /* Ignore nat/SharedIP dummy pcbs */
+ if (inp->inp_socket == &tcbinfo.nat_dummy_socket)
+ continue;
+
+ if (inp->inp_wantcnt != WNT_STOPUSING)
+ continue;
+
+ so = inp->inp_socket;
+ if (!lck_mtx_try_lock(inp->inpcb_mtx)) {/* skip if in use */
+#if TEMPDEBUG
+ printf("tcp_slowtimo so=%x STOPUSING but locked...\n", so);
+#endif
+ continue;
+ }
+
+ if (so->so_usecount == 0)
+ in_pcbdispose(inp);
+ else {
+ tp = intotcpcb(inp);
+ /* Check for embryonic socket stuck on listener queue (4023660) */
+ if ((so->so_usecount == 1) && (tp->t_state == TCPS_CLOSED) &&
+ (so->so_head != NULL) && (so->so_state & SS_INCOMP)) {
+ so->so_usecount--;
+ in_pcbdispose(inp);
+ } else
+ lck_mtx_unlock(inp->inpcb_mtx);
+ }