Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not start SCTP iterator thread when library is initialized via usrsctp_init_nothreads. #472

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions usrsctplib/netinet/sctp_bsd_addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ sctp_cleanup_itqueue(void)
void
sctp_wakeup_iterator(void)
{
if (!SCTP_BASE_VAR(iterator_thread_started)) {
// no dedicated thread stated, so execute
// iterator work on current thread
return sctp_iterator_worker();
}
#if defined(SCTP_PROCESS_LEVEL_LOCKS)
#if defined(__Userspace_os_Windows)
WakeAllConditionVariable(&sctp_it_ctl.iterator_wakeup);
Expand Down Expand Up @@ -177,7 +182,11 @@ sctp_iterator_thread(void *v SCTP_UNUSED)
}

void
#if defined(__Userspace__)
sctp_startup_iterator(int start_threads)
#else
sctp_startup_iterator(void)
#endif
{
if (sctp_it_ctl.thread_proc) {
/* You only get one */
Expand All @@ -187,6 +196,13 @@ sctp_startup_iterator(void)
SCTP_ITERATOR_LOCK_INIT();
SCTP_IPI_ITERATOR_WQ_INIT();
TAILQ_INIT(&sctp_it_ctl.iteratorhead);

#if defined(__Userspace__)
if (!start_threads) {
return;
}
#endif

#if defined(__FreeBSD__)
#if __FreeBSD_version <= 701000
kthread_create(sctp_iterator_thread,
Expand Down
7 changes: 6 additions & 1 deletion usrsctplib/netinet/sctp_bsd_addr.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ __FBSDID("$FreeBSD: head/sys/netinet/sctp_bsd_addr.h 353480 2019-10-13 18:17:08Z
extern struct iterator_control sctp_it_ctl;
void sctp_wakeup_iterator(void);

void sctp_startup_iterator(void);
void
#if defined(__Userspace__)
sctp_startup_iterator(int start_threads);
#else
sctp_startup_iterator(void);
#endif


#ifdef INET6
Expand Down
5 changes: 5 additions & 0 deletions usrsctplib/netinet/sctp_pcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -6799,7 +6799,12 @@ sctp_pcb_init(void)
(void)pthread_cond_init(&sctp_it_ctl.iterator_wakeup, NULL);
#endif
#endif

#if defined(__Userspace__)
sctp_startup_iterator(start_threads);
#else
sctp_startup_iterator();
#endif

#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
sctp_startup_mcore_threads();
Expand Down