X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcclient%2FREADME;h=dc0fcae7f11ff08cef98733ad8e077f942478266;hb=77336860c5d419c9d25a6366de0269c0edb38889;hp=66a14e7d072148aa85b4744ca57376063a251623;hpb=5e8e3a77c70f10a29e78aa645366c84564b8bc7d;p=silc.git diff --git a/lib/silcclient/README b/lib/silcclient/README index 66a14e7d..dc0fcae7 100644 --- a/lib/silcclient/README +++ b/lib/silcclient/README @@ -76,3 +76,26 @@ When to use FSM semaphore signalling? The call cannot fail. Semaphores need not be uninitialized and the same context may be reused. + +Finishing threads when closing connection + + When closing SilcClientConnection all threads must first be finished + before the connection machine is finished. This is done by finishing + all running command threads. That will also finish all waiting packet + threads as they are always waiting for a command. If any thread is + waiting for something else than a command (such as event threads) they + must be explicitly finished. The threads are finished by continuing + them synchronously. The threads will detect that we are disconnected + (see below). SILC_FSM_YIELD must be returned in st_close() as that + gives the FSM scheduler time to finish the threads first. After that + the machine can be finished. + + Also, any thread that runs in SilcClientConnection machine must always + after returning from wait state to check if we are disconnected by doing + + if (conn->internal->disconnected) + xxx; + + If disconnected the thread must finish immediately by returning + SILC_FSM_FINISH. +