mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Add more informative thread names
This commit is contained in:
parent
2e74acaabe
commit
380c892e24
4 changed files with 21 additions and 6 deletions
|
@ -81,6 +81,7 @@ import java.util.Set;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -749,6 +750,8 @@ public class ManagerImpl implements Manager {
|
|||
}
|
||||
}
|
||||
|
||||
private static final AtomicInteger threadNumber = new AtomicInteger(0);
|
||||
|
||||
private void startReceiveThreadIfRequired() {
|
||||
if (receiveThread != null) {
|
||||
return;
|
||||
|
@ -784,6 +787,7 @@ public class ManagerImpl implements Manager {
|
|||
}
|
||||
}
|
||||
});
|
||||
receiveThread.setName("receive-" + threadNumber.getAndIncrement());
|
||||
|
||||
receiveThread.start();
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||
logger.debug("Stopping msl cleanup thread");
|
||||
}
|
||||
});
|
||||
cleanupThread.setName("msl-cleanup");
|
||||
cleanupThread.setDaemon(true);
|
||||
cleanupThread.start();
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import java.nio.channels.SocketChannel;
|
|||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
||||
|
@ -234,8 +235,10 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||
});
|
||||
}
|
||||
|
||||
private static final AtomicInteger threadNumber = new AtomicInteger(0);
|
||||
|
||||
private void runSocket(final ServerSocketChannel serverChannel, Consumer<SocketChannel> socketHandler) {
|
||||
new Thread(() -> {
|
||||
final var thread = new Thread(() -> {
|
||||
while (true) {
|
||||
final SocketChannel channel;
|
||||
final String clientString;
|
||||
|
@ -250,16 +253,20 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||
}
|
||||
break;
|
||||
}
|
||||
new Thread(() -> {
|
||||
final var connectionThread = new Thread(() -> {
|
||||
try (final var c = channel) {
|
||||
socketHandler.accept(c);
|
||||
logger.info("Connection closed: " + clientString);
|
||||
} catch (IOException e) {
|
||||
logger.warn("Failed to close channel", e);
|
||||
}
|
||||
}).start();
|
||||
});
|
||||
connectionThread.setName("daemon-connection-" + threadNumber.getAndIncrement());
|
||||
connectionThread.start();
|
||||
}
|
||||
}).start();
|
||||
});
|
||||
thread.setName("daemon-listener");
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private SignalJsonRpcDispatcherHandler getSignalJsonRpcDispatcherHandler(
|
||||
|
@ -367,6 +374,7 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||
final var signal = new DbusSignalImpl(m, conn, objectPath, noReceiveOnStart);
|
||||
conn.exportObject(signal);
|
||||
final var initThread = new Thread(signal::initObjects);
|
||||
initThread.setName("dbus-init");
|
||||
initThread.start();
|
||||
|
||||
logger.debug("Exported dbus object: " + objectPath);
|
||||
|
|
|
@ -96,14 +96,16 @@ public class DbusSignalControlImpl implements org.asamk.SignalControl {
|
|||
public String link(final String newDeviceName) throws Error.Failure {
|
||||
try {
|
||||
final URI deviceLinkUri = c.getNewProvisioningDeviceLinkUri();
|
||||
new Thread(() -> {
|
||||
final var thread = new Thread(() -> {
|
||||
final ProvisioningManager provisioningManager = c.getProvisioningManagerFor(deviceLinkUri);
|
||||
try {
|
||||
provisioningManager.finishDeviceLink(newDeviceName);
|
||||
} catch (IOException | TimeoutException | UserAlreadyExists e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
});
|
||||
thread.setName("dbus-link");
|
||||
thread.start();
|
||||
return deviceLinkUri.toString();
|
||||
} catch (TimeoutException | IOException e) {
|
||||
throw new SignalControl.Error.Failure(e.getClass().getSimpleName() + " " + e.getMessage());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue