Kannel: Open Source WAP and SMS gateway
svn-r5336
|
#include <unistd.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <string.h>
#include "gwlib/gwlib.h"
Go to the source code of this file.
Data Structures | |
struct | threadinfo |
struct | new_thread_args |
Macros | |
#define | THREADTABLE_SIZE 4096 |
#define | THREAD(t) (threadtable[(t) % THREADTABLE_SIZE]) |
Functions | |
static void | lock (void) |
static void | unlock (void) |
static void | flushpipe (int fd) |
static long | fill_threadinfo (pthread_t id, const char *name, gwthread_func_t *func, struct threadinfo *ti) |
static struct threadinfo * | getthreadinfo (void) |
static void | alert_joiners (void) |
static void | delete_threadinfo (void) |
void | gwthread_init (void) |
void | gwthread_shutdown (void) |
static void | new_thread_cleanup (void *arg) |
static void * | new_thread (void *arg) |
static int | block_user_signals (sigset_t *old_set_storage) |
static void | restore_user_signals (sigset_t *old_set) |
static long | spawn_thread (gwthread_func_t *func, const char *name, void *arg) |
long | gwthread_create_real (gwthread_func_t *func, const char *name, void *arg) |
void | gwthread_join (long thread) |
void | gwthread_join_all (void) |
void | gwthread_wakeup_all (void) |
void | gwthread_join_every (gwthread_func_t *func) |
long | gwthread_self (void) |
long | gwthread_self_pid (void) |
void | gwthread_self_ids (long *tid, long *pid) |
void | gwthread_wakeup (long thread) |
int | gwthread_pollfd (int fd, int events, double timeout) |
int | gwthread_poll (struct pollfd *fds, long numfds, double timeout) |
void | gwthread_sleep (double seconds) |
void | gwthread_sleep_micro (double dseconds) |
int | gwthread_cancel (long thread) |
int | gwthread_shouldhandlesignal (int signal) |
int | gwthread_dumpsigmask (void) |
Variables | |
static struct threadinfo * | threadtable [THREADTABLE_SIZE] |
static long | active_threads = 0 |
static long | next_threadnumber |
static struct threadinfo | mainthread |
static pthread_key_t | tsd_key |
static pthread_mutex_t | threadtable_lock |
#define THREAD | ( | t | ) | (threadtable[(t) % THREADTABLE_SIZE]) |
Definition at line 107 of file gwthread-pthread.c.
Referenced by delete_threadinfo(), fill_threadinfo(), gwthread_cancel(), gwthread_join(), gwthread_join_all(), gwthread_join_every(), gwthread_wakeup(), and gwthread_wakeup_all().
#define THREADTABLE_SIZE 4096 |
Definition at line 78 of file gwthread-pthread.c.
Referenced by fill_threadinfo(), gwthread_init(), gwthread_join_all(), gwthread_join_every(), gwthread_shutdown(), gwthread_wakeup_all(), and spawn_thread().
|
static |
Definition at line 236 of file gwthread-pthread.c.
References getthreadinfo(), gwlist_extract_first(), and threadinfo::joiners.
Referenced by new_thread_cleanup().
|
static |
Definition at line 415 of file gwthread-pthread.c.
References error().
Referenced by gwthread_create_real().
|
static |
Definition at line 249 of file gwthread-pthread.c.
References active_threads, getthreadinfo(), gw_assert(), gwlist_destroy(), threadinfo::joiners, mainthread, threadinfo::number, THREAD, threadinfo::wakefd_recv, and threadinfo::wakefd_send.
Referenced by new_thread_cleanup().
|
static |
Definition at line 167 of file gwthread-pthread.c.
References active_threads, error(), threadinfo::func, gw_assert(), threadinfo::joiners, threadinfo::name, name, next_threadnumber, threadinfo::number, threadinfo::pid, threadinfo::self, socket_set_blocking(), THREAD, THREADTABLE_SIZE, threadinfo::wakefd_recv, and threadinfo::wakefd_send.
Referenced by gwthread_init(), and spawn_thread().
|
static |
Definition at line 153 of file gwthread-pthread.c.
Referenced by gwthread_poll(), gwthread_pollfd(), gwthread_sleep(), and gwthread_sleep_micro().
|
static |
Definition at line 218 of file gwthread-pthread.c.
References gw_assert(), panic, threadinfo::self, and tsd_key.
Referenced by alert_joiners(), delete_threadinfo(), gwthread_poll(), gwthread_pollfd(), gwthread_sleep(), and gwthread_sleep_micro().
int gwthread_cancel | ( | long | thread | ) |
Definition at line 843 of file gwthread-pthread.c.
References debug(), gw_assert(), lock(), threadinfo::name, threadinfo::number, threadinfo::self, THREAD, and unlock().
Referenced by main().
long gwthread_create_real | ( | gwthread_func_t * | func, |
const char * | name, | ||
void * | arg | ||
) |
Definition at line 508 of file gwthread-pthread.c.
References new_thread_args::arg, block_user_signals(), new_thread_args::func, gwthread_self(), MAIN_THREAD_ID, name, restore_user_signals(), and spawn_thread().
int gwthread_dumpsigmask | ( | void | ) |
void gwthread_init | ( | void | ) |
Definition at line 267 of file gwthread-pthread.c.
References active_threads, fill_threadinfo(), mainthread, panic, threadtable, threadtable_lock, THREADTABLE_SIZE, and tsd_key.
Referenced by gwlib_init().
void gwthread_join | ( | long | thread | ) |
Definition at line 541 of file gwthread-pthread.c.
References gw_assert(), gwlist_append(), gwlist_create, threadinfo::joiners, lock(), threadinfo::number, THREAD, threadtable_lock, unlock(), and warning().
Referenced by cimd2_shutdown_cb(), emi2_sender(), fdset_destroy(), gw_timerset_destroy(), gw_timerset_elapsed_destroy(), gwthread_join_all(), heartbeat_stop(), httpd_emu_destroy(), httpsmsc_receiver(), httpsmsc_sender(), io_thread(), main(), oisd_shutdown_cb(), receive_smpp_thread(), run_smppbox(), run_smsbox(), run_sqlbox(), run_wapbox(), shutdown_cb(), smpp_emu(), smpp_emu_reader(), smsboxc_run(), smsc_cimd2_create(), smsc_emi2_create(), smsc_emu_destroy(), smsc_oisd_create(), smsc_smpp_create(), soap_server_stop(), soap_shutdown_cb(), store_file_shutdown(), timers_shutdown(), udp_sender(), and wrapper_sender().
void gwthread_join_all | ( | void | ) |
Definition at line 585 of file gwthread-pthread.c.
References gwthread_join(), gwthread_self(), THREAD, and THREADTABLE_SIZE.
Referenced by main().
void gwthread_join_every | ( | gwthread_func_t * | func | ) |
Definition at line 607 of file gwthread-pthread.c.
References debug(), threadinfo::func, gwlist_append(), gwlist_create, threadinfo::joiners, lock(), threadinfo::name, threadinfo::number, THREAD, threadtable_lock, THREADTABLE_SIZE, unlock(), and warning().
Referenced by client_shutdown(), http_close_all_ports(), httpadmin_stop(), main(), main_for_producer_and_consumer(), radius_acct_shutdown(), server_shutdown(), wap_appl_shutdown(), wap_push_ota_shutdown(), wap_push_ppg_shutdown(), wsp_push_client_shutdown(), wsp_session_shutdown(), wsp_unit_shutdown(), wtp_initiator_shutdown(), and wtp_resp_shutdown().
int gwthread_poll | ( | struct pollfd * | fds, |
long | numfds, | ||
double | timeout | ||
) |
Definition at line 740 of file gwthread-pthread.c.
References error(), pollfd::events, pollfd::fd, flushpipe(), getthreadinfo(), poll, POLL_NOTIMEOUT, POLLIN, pollfd::revents, and threadinfo::wakefd_recv.
Referenced by poller(), and server_thread().
int gwthread_pollfd | ( | int | fd, |
int | events, | ||
double | timeout | ||
) |
Definition at line 706 of file gwthread-pthread.c.
References error(), pollfd::events, pollfd::fd, flushpipe(), getthreadinfo(), poll, POLL_NOTIMEOUT, POLLIN, pollfd::revents, and threadinfo::wakefd_recv.
Referenced by accept_thread(), cgw_listener(), cgw_wait_command(), conn_flush(), conn_wait(), emi2_listener(), fake_listener(), gw_accept(), and wait_for_connections().
long gwthread_self | ( | void | ) |
Definition at line 650 of file gwthread-pthread.c.
References threadinfo::number, and tsd_key.
Referenced by client_thread(), conn_claim(), fdset_destroy(), fdset_listen(), fdset_register(), fdset_set_timeout(), fdset_unregister(), find_entry(), format(), gw_prioqueue_consume(), gw_rwlock_unlock(), gw_rwlock_wrlock(), gwlist_consume(), gwlist_timed_consume(), gwlist_wait_until_nonempty(), gwthread_create_real(), gwthread_join_all(), gwthread_wakeup_all(), handle_action(), lock_in(), lock_out(), mutex_lock_real(), mutex_trylock_real(), new_thread_cleanup(), producer(), and push_thread().
void gwthread_self_ids | ( | long * | tid, |
long * | pid | ||
) |
Definition at line 671 of file gwthread-pthread.c.
References threadinfo::number, threadinfo::pid, and tsd_key.
Referenced by format().
long gwthread_self_pid | ( | void | ) |
Definition at line 661 of file gwthread-pthread.c.
References threadinfo::pid, and tsd_key.
int gwthread_shouldhandlesignal | ( | int | signal | ) |
Definition at line 867 of file gwthread-pthread.c.
Referenced by signal_handler().
void gwthread_shutdown | ( | void | ) |
Definition at line 296 of file gwthread-pthread.c.
References debug(), gw_assert(), lock(), name, number, running, threadtable, threadtable_lock, THREADTABLE_SIZE, unlock(), and warning().
Referenced by gwlib_shutdown().
void gwthread_sleep | ( | double | seconds | ) |
Definition at line 780 of file gwthread-pthread.c.
References pollfd::events, pollfd::fd, flushpipe(), getthreadinfo(), poll, POLL_NOTIMEOUT, POLLIN, threadinfo::wakefd_recv, and warning().
Referenced by at2_detect_modem_type(), at2_device_thread(), at2_init_device(), at2_login_device(), at2_send_one_message(), at2_write(), at2_write_ctrlz(), at2_write_line(), bb_smscconn_receive_internal(), cgw_open_send_connection(), client_thread(), emi2_do_send(), emi2_wait(), heartbeat_thread(), httpd_check_authorization(), httpsmsc_send_cb(), httpsmsc_sender(), io_thread(), main(), main_connection_loop(), open_send_connection(), parachute_start(), poller(), port_remove(), push_thread(), reconnect(), restart_box(), send_message(), send_messages(), send_smpp_thread(), server_thread(), smasi_thread(), smpp_to_bearerbox(), sms_router(), sms_to_smsboxes(), smsbox_thread(), smsboxc_run(), smsc2_graceful_restart(), soap_listener(), soap_server(), sql_list(), sql_single(), store_dumper(), thread1(), thread2(), wait_for_connections(), wapboxc_run(), watch_timers(), and wrapper_receiver().
void gwthread_sleep_micro | ( | double | dseconds | ) |
Definition at line 808 of file gwthread-pthread.c.
References flushpipe(), getthreadinfo(), threadinfo::wakefd_recv, and warning().
void gwthread_wakeup | ( | long | thread | ) |
Definition at line 684 of file gwthread-pthread.c.
References gw_assert(), lock(), threadinfo::number, THREAD, unlock(), and threadinfo::wakefd_send.
Referenced by add_msg_cb(), at2_add_msg_cb(), at2_shutdown_cb(), at2_start_cb(), bb_smscconn_connected(), boxc_receiver(), cgw_add_msg_cb(), cgw_listener(), cgw_shutdown_cb(), cgw_start_cb(), cimd2_add_msg_cb(), cimd2_shutdown_cb(), cimd2_start_cb(), client_destroy(), emi2_idleprocessing(), emi2_listener(), emi2_sender(), gw_timer_elapsed_start(), gw_timer_elapsed_start_cb(), gw_timer_start(), gw_timerset_destroy(), gw_timerset_elapsed_destroy(), gwthread_wakeup_all(), gwtimer_start(), heartbeat_stop(), http_close_all_ports(), http_close_port(), http_open_port_if(), httpd_shutdown(), httpsmsc_receiver(), httpsmsc_sender(), httpsmsc_shutdown(), io_thread(), main(), oisd_add_msg_cb(), oisd_shutdown_cb(), oisd_start_cb(), run_smsbox(), send_msg_cb(), server_shutdown(), shutdown_cb(), smpp_emu(), sms_router(), smsboxc_run(), smsc2_graceful_restart(), smsc2_restart_smsc(), smsc2_resume(), smsc2_shutdown(), smsc_cimd2_create(), smsc_emi2_create(), smsc_emu_destroy(), smsc_oisd_create(), smsc_smpp_create(), soap_add_msg_cb(), soap_server_stop(), soap_shutdown_cb(), start_cb(), store_file_shutdown(), submit_action(), submit_action_nosync(), timers_shutdown(), udp_receiver(), wapboxc_run(), wrapper_sender(), and wrapper_shutdown().
void gwthread_wakeup_all | ( | void | ) |
Definition at line 596 of file gwthread-pthread.c.
References gwthread_self(), gwthread_wakeup(), THREAD, and THREADTABLE_SIZE.
Referenced by httpd_restart(), main(), and quit().
|
inlinestatic |
Definition at line 131 of file gwthread-pthread.c.
References panic, and threadtable_lock.
Referenced by gwthread_cancel(), gwthread_join(), gwthread_join_every(), gwthread_shutdown(), gwthread_wakeup(), new_thread(), new_thread_cleanup(), and spawn_thread().
|
static |
Definition at line 354 of file gwthread-pthread.c.
References new_thread_args::arg, debug(), new_thread_args::failed, new_thread_args::func, lock(), threadinfo::name, new_thread_cleanup(), threadinfo::number, panic, threadinfo::pid, new_thread_args::ti, tsd_key, and unlock().
Referenced by spawn_thread().
|
static |
Definition at line 332 of file gwthread-pthread.c.
References alert_joiners(), new_thread_args::arg, debug(), delete_threadinfo(), gwthread_self(), lock(), threadinfo::name, threadinfo::number, new_thread_args::ti, and unlock().
Referenced by new_thread().
|
static |
Definition at line 442 of file gwthread-pthread.c.
References panic.
Referenced by gwthread_create_real().
|
static |
Definition at line 453 of file gwthread-pthread.c.
References active_threads, new_thread_args::arg, debug(), error(), new_thread_args::failed, fill_threadinfo(), new_thread_args::func, lock(), name, new_thread(), THREADTABLE_SIZE, new_thread_args::ti, and unlock().
Referenced by gwthread_create_real().
|
inlinestatic |
Definition at line 141 of file gwthread-pthread.c.
References panic, and threadtable_lock.
Referenced by gwthread_cancel(), gwthread_join(), gwthread_join_every(), gwthread_shutdown(), gwthread_wakeup(), new_thread(), new_thread_cleanup(), and spawn_thread().
|
static |
Definition at line 110 of file gwthread-pthread.c.
Referenced by delete_threadinfo(), fill_threadinfo(), gwthread_init(), and spawn_thread().
|
static |
Definition at line 122 of file gwthread-pthread.c.
Referenced by delete_threadinfo(), and gwthread_init().
|
static |
Definition at line 116 of file gwthread-pthread.c.
Referenced by fill_threadinfo().
|
static |
Definition at line 106 of file gwthread-pthread.c.
Referenced by gwthread_init(), and gwthread_shutdown().
|
static |
Definition at line 129 of file gwthread-pthread.c.
Referenced by gwthread_init(), gwthread_join(), gwthread_join_every(), gwthread_shutdown(), lock(), and unlock().
|
static |
Definition at line 127 of file gwthread-pthread.c.
Referenced by getthreadinfo(), gwthread_init(), gwthread_self(), gwthread_self_ids(), gwthread_self_pid(), and new_thread().