19#if COAP_THREAD_RECURSIVE_CHECK
21coap_lock_unlock_func(
coap_lock_t *lock,
const char *file,
int line) {
23 if (lock->in_callback) {
24 assert(lock->lock_count > 0);
28 lock->unlock_file = file;
29 lock->unlock_line = line;
35coap_lock_lock_func(
coap_lock_t *lock,
const char *file,
int line) {
43 if (lock->in_callback) {
46 assert(lock->in_callback == lock->lock_count);
50 lock->lock_file, lock->lock_line, file, line);
58 assert(!lock->in_callback);
60 lock->lock_file = file;
61 lock->lock_line = line;
70 if (lock->in_callback) {
71 assert(lock->lock_count > 0);
91 assert(lock->in_callback == lock->lock_count);
96 assert(!lock->in_callback);
104static pthread_t *thread_id =
NULL;
105static uint32_t thread_id_count = 0;
110uint32_t max_thread_no = 0;
115} coap_thread_param_t;
118coap_io_process_worker_thread(
void *arg) {
119 coap_thread_param_t *thread_param = (coap_thread_param_t *)arg;
121#if (COAP_MAX_LOGGING_LEVEL >= _COAP_LOG_DEBUG)
125 thread_no = thread_param->thread_no;
155 max_thread_no = 1 + thread_count;
159 coap_log_err(
"thread start up memory allocate failure\n");
163 for (i = 0; i < thread_count ; i++) {
167 thread_param->context = context;
168 thread_param->thread_no = i + 2;
169 s = pthread_create(&thread_id[i],
NULL,
170 &coap_io_process_worker_thread, thread_param);
195 for (i = 0; i < thread_id_count ; i++) {
196 int s = pthread_kill(thread_id[i], SIGINT);
206 for (i = 0; i < thread_id_count ; i++) {
208 int s = pthread_join(thread_id[i], &retval);
const char * coap_socket_strerror(void)
volatile int coap_thread_quit
Library specific build wrapper for coap_internal.h.
void * coap_malloc_type(coap_memory_tag_t type, size_t size)
Allocates a chunk of size bytes and returns a pointer to the newly allocated memory.
void coap_free_type(coap_memory_tag_t type, void *p)
Releases the memory that was allocated by coap_malloc_type().
#define coap_mutex_unlock(a)
#define coap_mutex_trylock(a)
#define coap_mutex_lock(a)
int coap_io_process_lkd(coap_context_t *ctx, uint32_t timeout_ms)
The main I/O processing function.
int coap_io_process_configure_threads(coap_context_t *context, uint32_t thread_count)
Configure a defined number of threads to do the alternate coap_io_process() work with traffic load ba...
void coap_io_process_remove_threads(coap_context_t *context)
Release the coap_io_process() worker threads.
void coap_send_recv_terminate(void)
Terminate any active coap_send_recv() sessions.
void coap_dtls_thread_shutdown(void)
Close down the underlying (D)TLS Library layer.
#define coap_lock_unlock()
Dummy for no thread-safe code.
#define coap_lock_lock(failed)
Dummy for no thread-safe code.
#define coap_log_debug(...)
#define coap_log_alert(...)
#define coap_log_err(...)
#define COAP_THREAD_LOCAL_VAR
The CoAP stack's global state is stored in a coap_context_t object.