svn commit: r225676 - head/sys/netinet
Michael Tuexen
tuexen at FreeBSD.org
Mon Sep 19 21:47:21 UTC 2011
Author: tuexen
Date: Mon Sep 19 21:47:20 2011
New Revision: 225676
URL: http://svn.freebsd.org/changeset/base/225676
Log:
Cleanup the iterator code, remove code that is never executed.
Approved by: re
MFC after: 1 month.
Modified:
head/sys/netinet/sctp_bsd_addr.c
head/sys/netinet/sctp_structs.h
head/sys/netinet/sctputil.c
Modified: head/sys/netinet/sctp_bsd_addr.c
==============================================================================
--- head/sys/netinet/sctp_bsd_addr.c Mon Sep 19 18:29:15 2011 (r225675)
+++ head/sys/netinet/sctp_bsd_addr.c Mon Sep 19 21:47:20 2011 (r225676)
@@ -74,22 +74,6 @@ MALLOC_DEFINE(SCTP_M_MCORE, "sctp_mcore"
/* Global NON-VNET structure that controls the iterator */
struct iterator_control sctp_it_ctl;
-static int __sctp_thread_based_iterator_started = 0;
-
-
-static void
-sctp_cleanup_itqueue(void)
-{
- struct sctp_iterator *it, *nit;
-
- TAILQ_FOREACH_SAFE(it, &sctp_it_ctl.iteratorhead, sctp_nxt_itr, nit) {
- if (it->function_atend != NULL) {
- (*it->function_atend) (it->pointer, it->val);
- }
- TAILQ_REMOVE(&sctp_it_ctl.iteratorhead, it, sctp_nxt_itr);
- SCTP_FREE(it, SCTP_M_ITER);
- }
-}
void
@@ -102,17 +86,11 @@ static void
sctp_iterator_thread(void *v)
{
SCTP_IPI_ITERATOR_WQ_LOCK();
+ /* In FreeBSD this thread never terminates. */
while (1) {
msleep(&sctp_it_ctl.iterator_running,
&sctp_it_ctl.ipi_iterator_wq_mtx,
0, "waiting_for_work", 0);
- if (sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) {
- SCTP_IPI_ITERATOR_WQ_DESTROY();
- SCTP_ITERATOR_LOCK_DESTROY();
- sctp_cleanup_itqueue();
- __sctp_thread_based_iterator_started = 0;
- kthread_exit();
- }
sctp_iterator_worker();
}
}
@@ -120,21 +98,21 @@ sctp_iterator_thread(void *v)
void
sctp_startup_iterator(void)
{
- if (__sctp_thread_based_iterator_started) {
+ static int called = 0;
+ int ret;
+
+ if (called) {
/* You only get one */
return;
}
/* init the iterator head */
- __sctp_thread_based_iterator_started = 1;
+ called = 1;
sctp_it_ctl.iterator_running = 0;
sctp_it_ctl.iterator_flags = 0;
sctp_it_ctl.cur_it = NULL;
SCTP_ITERATOR_LOCK_INIT();
SCTP_IPI_ITERATOR_WQ_INIT();
TAILQ_INIT(&sctp_it_ctl.iteratorhead);
-
- int ret;
-
ret = kproc_create(sctp_iterator_thread,
(void *)NULL,
&sctp_it_ctl.thread_proc,
Modified: head/sys/netinet/sctp_structs.h
==============================================================================
--- head/sys/netinet/sctp_structs.h Mon Sep 19 18:29:15 2011 (r225675)
+++ head/sys/netinet/sctp_structs.h Mon Sep 19 21:47:20 2011 (r225676)
@@ -185,9 +185,8 @@ struct iterator_control {
uint32_t iterator_flags;
};
-#define SCTP_ITERATOR_MUST_EXIT 0x00000001
-#define SCTP_ITERATOR_STOP_CUR_IT 0x00000002
-#define SCTP_ITERATOR_STOP_CUR_INP 0x00000004
+#define SCTP_ITERATOR_STOP_CUR_IT 0x00000004
+#define SCTP_ITERATOR_STOP_CUR_INP 0x00000008
struct sctp_net_route {
sctp_rtentry_t *ro_rt;
Modified: head/sys/netinet/sctputil.c
==============================================================================
--- head/sys/netinet/sctputil.c Mon Sep 19 18:29:15 2011 (r225675)
+++ head/sys/netinet/sctputil.c Mon Sep 19 21:47:20 2011 (r225676)
@@ -1293,10 +1293,6 @@ select_a_new_ep:
SCTP_INP_DECR_REF(it->inp);
atomic_add_int(&it->stcb->asoc.refcnt, -1);
if (sctp_it_ctl.iterator_flags &
- SCTP_ITERATOR_MUST_EXIT) {
- goto done_with_iterator;
- }
- if (sctp_it_ctl.iterator_flags &
SCTP_ITERATOR_STOP_CUR_IT) {
sctp_it_ctl.iterator_flags &= ~SCTP_ITERATOR_STOP_CUR_IT;
goto done_with_iterator;
@@ -1372,9 +1368,6 @@ sctp_iterator_worker(void)
sctp_it_ctl.cur_it = NULL;
CURVNET_RESTORE();
SCTP_IPI_ITERATOR_WQ_LOCK();
- if (sctp_it_ctl.iterator_flags & SCTP_ITERATOR_MUST_EXIT) {
- break;
- }
/* sa_ignore FREED_MEMORY */
}
sctp_it_ctl.iterator_running = 0;
More information about the svn-src-head
mailing list