svn commit: r295624 - projects/vnet/sys/netinet
Bjoern A. Zeeb
bz at FreeBSD.org
Mon Feb 15 12:34:49 UTC 2016
Author: bz
Date: Mon Feb 15 12:34:47 2016
New Revision: 295624
URL: https://svnweb.freebsd.org/changeset/base/295624
Log:
Cleanup the SCTP changes:
- backout the atomic change now that we seem to have the races under control
- make printfs SCTP_PRINTFs.
- cleanup comments.
Sponsored by: The FreeBSD Foundation
Modified:
projects/vnet/sys/netinet/sctp_bsd_addr.c
projects/vnet/sys/netinet/sctp_pcb.c
projects/vnet/sys/netinet/sctp_structs.h
projects/vnet/sys/netinet/sctputil.c
Modified: projects/vnet/sys/netinet/sctp_bsd_addr.c
==============================================================================
--- projects/vnet/sys/netinet/sctp_bsd_addr.c Mon Feb 15 07:35:40 2016 (r295623)
+++ projects/vnet/sys/netinet/sctp_bsd_addr.c Mon Feb 15 12:34:47 2016 (r295624)
@@ -77,7 +77,7 @@ struct iterator_control sctp_it_ctl;
void
sctp_wakeup_iterator(void)
{
- wakeup(&sctp_it_ctl.iterator_flags);
+ wakeup(&sctp_it_ctl.iterator_running);
}
static void
@@ -86,7 +86,7 @@ sctp_iterator_thread(void *v SCTP_UNUSED
SCTP_IPI_ITERATOR_WQ_LOCK();
/* In FreeBSD this thread never terminates. */
for (;;) {
- msleep(&sctp_it_ctl.iterator_flags,
+ msleep(&sctp_it_ctl.iterator_running,
&sctp_it_ctl.ipi_iterator_wq_mtx,
0, "waiting_for_work", 0);
sctp_iterator_worker();
Modified: projects/vnet/sys/netinet/sctp_pcb.c
==============================================================================
--- projects/vnet/sys/netinet/sctp_pcb.c Mon Feb 15 07:35:40 2016 (r295623)
+++ projects/vnet/sys/netinet/sctp_pcb.c Mon Feb 15 12:34:47 2016 (r295624)
@@ -5920,7 +5920,7 @@ sctp_pcb_finish(void)
struct sctp_iterator *it, *nit;
if (SCTP_BASE_VAR(sctp_pcb_initialized) == 0) {
- printf("%s: race condition on teardown.\n", __func__);
+ SCTP_PRINTF("%s: race condition on teardown.\n", __func__);
return;
}
SCTP_BASE_VAR(sctp_pcb_initialized) = 0;
@@ -5942,8 +5942,7 @@ retry:
r = atomic_fetchadd_int(&sctp_it_ctl.iterator_running, 0);
if (r != 0 || sctp_it_ctl.cur_it != NULL) {
SCTP_IPI_ITERATOR_WQ_UNLOCK();
- /* XXX-BZ make this a statistics variable. */
- printf("%s: Iterator running while we held the lock. Retry. "
+ SCTP_PRINTF("%s: Iterator running while we held the lock. Retry. "
"r=%u cur_it=%p\n", __func__, r, sctp_it_ctl.cur_it);
DELAY(10);
goto retry;
@@ -7014,7 +7013,7 @@ sctp_initiate_iterator(inp_func inpf,
return (-1);
}
if (SCTP_BASE_VAR(sctp_pcb_initialized) == 0) {
- printf("%s: abort on initialize being %d\n", __func__,
+ SCTP_PRINTF("%s: abort on initialize being %d\n", __func__,
SCTP_BASE_VAR(sctp_pcb_initialized));
return (-1);
}
@@ -7058,14 +7057,14 @@ sctp_initiate_iterator(inp_func inpf,
SCTP_IPI_ITERATOR_WQ_LOCK();
if (SCTP_BASE_VAR(sctp_pcb_initialized) == 0) {
SCTP_IPI_ITERATOR_WQ_UNLOCK();
- printf("%s: rollback on initialize being %d it=%p\n", __func__,
- SCTP_BASE_VAR(sctp_pcb_initialized), it);
+ SCTP_PRINTF("%s: rollback on initialize being %d it=%p\n",
+ __func__, SCTP_BASE_VAR(sctp_pcb_initialized), it);
SCTP_FREE(it, SCTP_M_ITER);
return (-1);
}
TAILQ_INSERT_TAIL(&sctp_it_ctl.iteratorhead, it, sctp_nxt_itr);
- if (atomic_fetchadd_int(&sctp_it_ctl.iterator_running, 0) == 0) {
+ if (sctp_it_ctl.iterator_running == 0) {
sctp_wakeup_iterator();
}
SCTP_IPI_ITERATOR_WQ_UNLOCK();
Modified: projects/vnet/sys/netinet/sctp_structs.h
==============================================================================
--- projects/vnet/sys/netinet/sctp_structs.h Mon Feb 15 07:35:40 2016 (r295623)
+++ projects/vnet/sys/netinet/sctp_structs.h Mon Feb 15 12:34:47 2016 (r295624)
@@ -180,7 +180,7 @@ struct iterator_control {
SCTP_PROCESS_STRUCT thread_proc;
struct sctpiterators iteratorhead;
struct sctp_iterator *cur_it;
- volatile uint32_t iterator_running;
+ uint32_t iterator_running;
uint32_t iterator_flags;
};
Modified: projects/vnet/sys/netinet/sctputil.c
==============================================================================
--- projects/vnet/sys/netinet/sctputil.c Mon Feb 15 07:35:40 2016 (r295623)
+++ projects/vnet/sys/netinet/sctputil.c Mon Feb 15 12:34:47 2016 (r295624)
@@ -1421,7 +1421,7 @@ sctp_iterator_worker(void)
/* This function is called with the WQ lock in place */
- atomic_store_rel_int(&sctp_it_ctl.iterator_running, 1);
+ sctp_it_ctl.iterator_running = 1;
TAILQ_FOREACH_SAFE(it, &sctp_it_ctl.iteratorhead, sctp_nxt_itr, nit) {
sctp_it_ctl.cur_it = it;
/* now lets work on this one */
@@ -1434,7 +1434,7 @@ sctp_iterator_worker(void)
SCTP_IPI_ITERATOR_WQ_LOCK();
/* sa_ignore FREED_MEMORY */
}
- atomic_store_rel_int(&sctp_it_ctl.iterator_running, 0);
+ sctp_it_ctl.iterator_running = 0;
return;
}
@@ -1483,7 +1483,7 @@ sctp_handle_addr_wq(void)
if (ret) {
SCTP_PRINTF("Failed to initiate iterator for handle_addr_wq\n");
SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTPUTIL, EFAULT);
- /* XXX-BZ Freeing if we are stopping or put back on the addr_wq. */
+ /* Freeing if we are stopping; putting back on the addr_wq otherwise. */
if (SCTP_BASE_VAR(sctp_pcb_initialized) == 0) {
sctp_asconf_iterator_end(asc, 0);
} else {
More information about the svn-src-projects
mailing list