Closed Demetriy closed 5 years ago
This is a sanity check that td_json_client_receive
is not run while the client is being destroyed. td_json_client_destroy
completly destroys a client, so the client must not be used from other threads at that time. To properly close the client, you need to call close
method and wait for updateAuthorizationState
with authorizationStateClosed
. After that you can stop to call td_json_client_receive
and can destroy the client via td_json_client_destroy
.
Thanks! I solved my problem with your help :)
@levlam Just a question. Telegram clients created in different threads are completely independent from one another right? i.e. one thread closing/destroying it's client doesn't affect other clients in different thread that were created independently.
also if a file is currently being downloaded and the client is destroyed does it also result in that Check !is_locked error?
@chairus All TDLib clients are independent and doesn't affect each other, except competing for system resources. Client's thread doesn't matter.
Check !is_locked
is always an application error, which tries to destroy the client while it is still being used in another thread. It doesn't matter whether some download file or other pending operation is in progress.
I'm using modified example of this code https://github.com/tdlib/td/blob/master/example/swift/src/main.swift, previously in tdlib 1.3 when user drops app in background i destroyed client with td_json_client_destroy(client), but in 1.4 i'm started to get messages: [1;31m[ 0][t 0][1560468306.749094009][Client.cpp:269] Check
!is_locked
failedHow can i properly close connection on app background and then create it again in 1.4?