diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2020-04-30 16:01:32 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2020-04-30 16:01:32 +0300 |
commit | 1379690841d68fe8b220104eb13780fb353503b3 (patch) | |
tree | 622e874ab6a9067f44cc519116210f8d6b86909b | |
parent | 757f98a5805a91c34f70bf090c01e6a9be235716 (diff) | |
download | wydawca-1379690841d68fe8b220104eb13780fb353503b3.tar.gz wydawca-1379690841d68fe8b220104eb13780fb353503b3.tar.bz2 |
Revise the triplet names. Update the docs.
-rw-r--r-- | doc/Makefile.am | 2 | ||||
-rw-r--r-- | doc/threads.texi | 54 | ||||
-rw-r--r-- | doc/wydawca.texi | 5 | ||||
-rw-r--r-- | src/net.c | 6 | ||||
-rw-r--r-- | src/timer.c | 2 | ||||
-rw-r--r-- | src/triplet.c | 4 |
6 files changed, 66 insertions, 7 deletions
diff --git a/doc/Makefile.am b/doc/Makefile.am index aaa2a3d..c1f3c44 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -15,7 +15,7 @@ # with Wydawca. If not, see <http://www.gnu.org/licenses/>. info_TEXINFOS=wydawca.texi -wydawca_TEXINFOS=fdl.texi macros.texi +wydawca_TEXINFOS=fdl.texi macros.texi threads.texi EXTRA_DIST = gendocs_template diff --git a/doc/threads.texi b/doc/threads.texi new file mode 100644 index 0000000..6dd2226 --- /dev/null +++ b/doc/threads.texi @@ -0,0 +1,54 @@ +This appendix outlines the structure of the program. It serves as a +short reminder for debugging the program. + +A running @command{wydawca} process consists of at least four threads. +Each upload is processed by its dedicated thread. Additional threads +can be strarted to perform some specific tasks. + +If the operating system permits, each thread is assigned a name. +Apart from the main thread, names of each thread begin with uppercase +letters @sc{WY} plus underscore. + +On a GNU/Linux system the name of a thread can be read from +@file{/proc/@var{pid}/task/@var{tid}/comm}, where @var{pid} is the PID +of the @command{wydawca} process and @var{tid} is the thread identifier. + +The following table describes each thread: + +@table @samp +@item wydawca +The main thread. It starts all other threads and waits for signals. +When it exits, all other threads are terminated as well. + +@item WY_listener +The workhorse of the project. Listens on inotify descriptor and TCP +socket for incoming notification events. This thread keeps a table of +uploaded files, which is updated each time an inotify event is +reported. Uploaded files are verified and ordered into triplets. Once +a triplet is completed, a separate @samp{WY_triplet} thread is started +in order to process it. + +If an incoming connection appears on upload notification socket +(@pxref{upload notification}), a @samp{WY_tcpmux} thread is started to +handle it. + +@item WY_tricleaner +Keeps track of registered triplets and removes expired ones. + +@item WY_stat +This thread is responsible for statistic logging and notification. + +@item WY_connwatch +This thread is started by if the legacy upload notification is enabled +(@pxref{daemon, listen}). It enforces idle timeout for +all started upload notification threads (@samp{WY_tcpmux} instances). + +@item WY_tcpmux +Serves a particular notification upload connection. The number of +threads of this type is limited by the @code{max-connections} +configuration file statement (@pxref{daemon, max-connections}). + +@item WY_triplet +Processes a triplet. A separate thread of this type is started by +@samp{WY_listener} for each valid triplet it detects. +@end table diff --git a/doc/wydawca.texi b/doc/wydawca.texi index a5dea41..1f7ffba 100644 --- a/doc/wydawca.texi +++ b/doc/wydawca.texi @@ -78,6 +78,7 @@ documents Wydawca Version @value{VERSION}. Appendices +* Architecture:: Outline of the Program Architecture * Copying This Manual:: The GNU Free Documentation License. * Concept Index:: Index of Concepts. @@ -3791,6 +3792,10 @@ file along with your bug report. This file is created after running @command{./configure} in @command{wydawca} source root directory. @end itemize +@node Architecture +@appendix Architecture of the Wydawca +@include threads.texi + @node Copying This Manual @appendix GNU Free Documentation License @include fdl.texi @@ -233,7 +233,7 @@ void * wy_thr_tcpmux(void *ptr) { struct wydawca_connection *conn = ptr; - wy_set_cur_thread_name("tcpmux"); + wy_set_cur_thread_name("WY_tcpmux"); pthread_cleanup_push((void (*)(void*))connection_stop, conn); setlinebuf(conn->fp); handle_connection(conn); @@ -244,7 +244,7 @@ wy_thr_tcpmux(void *ptr) void * wy_thr_connection_watcher(void *ptr) { - wy_set_cur_thread_name("connwatch"); + wy_set_cur_thread_name("WY_connwatch"); pthread_mutex_lock(&conn_mutex); while (1) { struct wydawca_connection *conn; @@ -283,7 +283,7 @@ wy_thr_listen(void *ptr) int wfd = watcher_init(); int maxfd = 0; - wy_set_cur_thread_name("listener"); + wy_set_cur_thread_name("WY_listener"); if (ctlfd != -1) { pthread_t tid; diff --git a/src/timer.c b/src/timer.c index e9ceaad..2cf3c24 100644 --- a/src/timer.c +++ b/src/timer.c @@ -263,7 +263,7 @@ struct micronent stat_report_schedule; void * wy_thr_stat(void *ptr) { - wy_set_cur_thread_name("statcol"); + wy_set_cur_thread_name("WY_stat"); pthread_mutex_lock(&global_stats_mutex); /* export the thread's specific stats and timer pointers to wydawca_global_stats and wydawca_global_stats. */ diff --git a/src/triplet.c b/src/triplet.c index f1c5b6f..627931e 100644 --- a/src/triplet.c +++ b/src/triplet.c @@ -475,7 +475,7 @@ triplet_expired_p(struct wy_triplet *trp) void * wy_thr_cleaner(void *ptr) { - wy_set_cur_thread_name("tricleaner"); + wy_set_cur_thread_name("WY_tricleaner"); triplet_list_lock(&triplet_pending_list); while (1) { if (!TAILQ_EMPTY(&triplet_pending_list.head)) { @@ -514,7 +514,7 @@ void * wy_thr_triplet(void *ptr) { struct wy_triplet *trp = ptr; - wy_set_cur_thread_name("triplet"); + wy_set_cur_thread_name("WY_triplet"); triplet_commit(trp); wydawca_stat_update(); remove_triplet(trp); |