提交 14e93745 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Update usrsctp (should fix #362)

上级 ea5b0dc5
...@@ -203,6 +203,8 @@ sctp_startup_iterator(void) ...@@ -203,6 +203,8 @@ sctp_startup_iterator(void)
#elif defined(__Userspace__) #elif defined(__Userspace__)
if (sctp_userspace_thread_create(&sctp_it_ctl.thread_proc, &sctp_iterator_thread)) { if (sctp_userspace_thread_create(&sctp_it_ctl.thread_proc, &sctp_iterator_thread)) {
SCTP_PRINTF("ERROR: Creating sctp_iterator_thread failed.\n"); SCTP_PRINTF("ERROR: Creating sctp_iterator_thread failed.\n");
} else {
SCTP_BASE_VAR(iterator_thread_started) = 1;
} }
#endif #endif
} }
......
...@@ -227,6 +227,8 @@ sctp_start_timer(void) ...@@ -227,6 +227,8 @@ sctp_start_timer(void)
rc = sctp_userspace_thread_create(&SCTP_BASE_VAR(timer_thread), user_sctp_timer_iterate); rc = sctp_userspace_thread_create(&SCTP_BASE_VAR(timer_thread), user_sctp_timer_iterate);
if (rc) { if (rc) {
SCTP_PRINTF("ERROR; return code from sctp_thread_create() is %d\n", rc); SCTP_PRINTF("ERROR; return code from sctp_thread_create() is %d\n", rc);
} else {
SCTP_BASE_VAR(timer_thread_started) = 1;
} }
} }
......
...@@ -6782,7 +6782,13 @@ sctp_pcb_init(void) ...@@ -6782,7 +6782,13 @@ sctp_pcb_init(void)
(void)pthread_cond_init(&sctp_it_ctl.iterator_wakeup, NULL); (void)pthread_cond_init(&sctp_it_ctl.iterator_wakeup, NULL);
#endif #endif
#endif #endif
#if defined(__Userspace__)
if (start_threads) {
sctp_startup_iterator(); sctp_startup_iterator();
}
#else
sctp_startup_iterator();
#endif
#if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP) #if defined(__FreeBSD__) && defined(SCTP_MCORE_INPUT) && defined(SMP)
sctp_startup_mcore_threads(); sctp_startup_mcore_threads();
......
...@@ -315,6 +315,8 @@ struct sctp_base_info { ...@@ -315,6 +315,8 @@ struct sctp_base_info {
userland_mutex_t timer_mtx; userland_mutex_t timer_mtx;
userland_thread_t timer_thread; userland_thread_t timer_thread;
int timer_thread_should_exit; int timer_thread_should_exit;
int iterator_thread_started;
int timer_thread_started;
#if !defined(__Userspace_os_Windows) #if !defined(__Userspace_os_Windows)
pthread_mutexattr_t mtx_attr; pthread_mutexattr_t mtx_attr;
#if defined(INET) || defined(INET6) #if defined(INET) || defined(INET6)
......
...@@ -161,11 +161,14 @@ sctp_init(void) ...@@ -161,11 +161,14 @@ sctp_init(void)
SCTP_BASE_VAR(conn_output) = conn_output; SCTP_BASE_VAR(conn_output) = conn_output;
SCTP_BASE_VAR(debug_printf) = debug_printf; SCTP_BASE_VAR(debug_printf) = debug_printf;
SCTP_BASE_VAR(crc32c_offloaded) = 0; SCTP_BASE_VAR(crc32c_offloaded) = 0;
SCTP_BASE_VAR(iterator_thread_started) = 0;
SCTP_BASE_VAR(timer_thread_started) = 0;
#endif #endif
#if defined(__Userspace__) #if defined(__Userspace__)
sctp_pcb_init(start_threads); sctp_pcb_init(start_threads);
if (start_threads) if (start_threads) {
sctp_start_timer(); sctp_start_timer();
}
#else #else
sctp_pcb_init(); sctp_pcb_init();
#endif #endif
...@@ -252,12 +255,14 @@ sctp_finish(void) ...@@ -252,12 +255,14 @@ sctp_finish(void)
} }
#endif #endif
atomic_cmpset_int(&SCTP_BASE_VAR(timer_thread_should_exit), 0, 1); atomic_cmpset_int(&SCTP_BASE_VAR(timer_thread_should_exit), 0, 1);
if (SCTP_BASE_VAR(timer_thread_started)) {
#if defined(__Userspace_os_Windows) #if defined(__Userspace_os_Windows)
WaitForSingleObject(SCTP_BASE_VAR(timer_thread), INFINITE); WaitForSingleObject(SCTP_BASE_VAR(timer_thread), INFINITE);
CloseHandle(SCTP_BASE_VAR(timer_thread)); CloseHandle(SCTP_BASE_VAR(timer_thread));
#else #else
pthread_join(SCTP_BASE_VAR(timer_thread), NULL); pthread_join(SCTP_BASE_VAR(timer_thread), NULL);
#endif #endif
}
#endif #endif
sctp_pcb_finish(); sctp_pcb_finish();
#if defined(__Windows__) #if defined(__Windows__)
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论