Fix race condition
This commit is contained in:
parent
83561e1d1b
commit
c156313fee
@ -1,7 +1,5 @@
|
||||
package it.tdlight.common;
|
||||
|
||||
import it.tdlight.jni.TdApi;
|
||||
|
||||
public abstract class CommonClientManager {
|
||||
|
||||
private static InternalClientManager getClientManager(String implementationName) {
|
||||
@ -34,8 +32,6 @@ public abstract class CommonClientManager {
|
||||
}
|
||||
|
||||
private static TelegramClient create(InternalClient internalClient) {
|
||||
// Send a dummy request because @levlam is too lazy to fix race conditions in a better way
|
||||
internalClient.send(new TdApi.GetAuthorizationState(), null, null);
|
||||
return internalClient;
|
||||
}
|
||||
}
|
||||
|
@ -44,13 +44,18 @@ public class InternalClient implements ClientEventsHandler, TelegramClient {
|
||||
UpdatesHandler updatesHandler,
|
||||
ExceptionHandler updateExceptionHandler,
|
||||
ExceptionHandler defaultExceptionHandler) {
|
||||
this.updateHandler = null;
|
||||
this.updatesHandler = new MultiHandler(updatesHandler, updateExceptionHandler);
|
||||
this.clientManager = clientManager;
|
||||
this.defaultExceptionHandler = defaultExceptionHandler;
|
||||
this.clientId = NativeClientAccess.create();
|
||||
clientInitializationLock.writeLock().lock();
|
||||
try {
|
||||
this.updateHandler = null;
|
||||
this.updatesHandler = new MultiHandler(updatesHandler, updateExceptionHandler);
|
||||
this.clientManager = clientManager;
|
||||
this.defaultExceptionHandler = defaultExceptionHandler;
|
||||
this.clientId = NativeClientAccess.create();
|
||||
|
||||
clientManager.registerClient(clientId, this);
|
||||
clientManager.registerClient(clientId, this);
|
||||
} finally {
|
||||
clientInitializationLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user