transaction: Also log to journal when processes connect to txn
We have logging when a "client" connects to us over the main bus, but none when a "process" connects to the transaction-private DBus socket. It's going to help us debug problems to log the latter. In the future we can try to correlate them, but for now simple logging in a similar way should help.
This commit is contained in:
parent
0c5820fd69
commit
3065554ba1
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <libglnx.h>
|
#include <libglnx.h>
|
||||||
#include <systemd/sd-journal.h>
|
#include <systemd/sd-journal.h>
|
||||||
|
#include <systemd/sd-login.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "rpmostreed-transaction.h"
|
#include "rpmostreed-transaction.h"
|
||||||
@ -121,6 +122,18 @@ transaction_maybe_emit_closed (RpmostreedTransaction *self)
|
|||||||
rpmostreed_sysroot_finish_txn (rpmostreed_sysroot_get (), self);
|
rpmostreed_sysroot_finish_txn (rpmostreed_sysroot_get (), self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
creds_to_string (GCredentials *creds)
|
||||||
|
{
|
||||||
|
auto uid = g_credentials_get_unix_user (creds, NULL);
|
||||||
|
auto pid = g_credentials_get_unix_pid (creds, NULL);
|
||||||
|
g_autofree char *unit = NULL;
|
||||||
|
if (pid != -1)
|
||||||
|
sd_pid_get_unit (pid, &unit);
|
||||||
|
|
||||||
|
return g_strdup_printf ("[pid: %u uid: %u unit: %s]", (guint32) pid, (guint32) uid, unit ?: "(unknown)");
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
transaction_connection_closed_cb (GDBusConnection *connection,
|
transaction_connection_closed_cb (GDBusConnection *connection,
|
||||||
gboolean remote_peer_vanished,
|
gboolean remote_peer_vanished,
|
||||||
@ -129,8 +142,11 @@ transaction_connection_closed_cb (GDBusConnection *connection,
|
|||||||
{
|
{
|
||||||
RpmostreedTransactionPrivate *priv = rpmostreed_transaction_get_private (self);
|
RpmostreedTransactionPrivate *priv = rpmostreed_transaction_get_private (self);
|
||||||
|
|
||||||
g_debug ("%s (%p): Client disconnected",
|
g_autofree char *creds = creds_to_string (g_dbus_connection_get_peer_credentials (connection));
|
||||||
G_OBJECT_TYPE_NAME (self), self);
|
if (remote_peer_vanished)
|
||||||
|
sd_journal_print (LOG_INFO, "Process %s disconnected from transaction progress", creds);
|
||||||
|
else
|
||||||
|
sd_journal_print (LOG_INFO, "Disconnecting process %s from transaction progress", creds);
|
||||||
|
|
||||||
g_hash_table_remove (priv->peer_connections, connection);
|
g_hash_table_remove (priv->peer_connections, connection);
|
||||||
|
|
||||||
@ -162,8 +178,8 @@ transaction_new_connection_cb (GDBusServer *server,
|
|||||||
|
|
||||||
g_hash_table_add (priv->peer_connections, g_object_ref (connection));
|
g_hash_table_add (priv->peer_connections, g_object_ref (connection));
|
||||||
|
|
||||||
g_debug ("%s (%p): Client connected",
|
g_autofree char *creds = creds_to_string (g_dbus_connection_get_peer_credentials (connection));
|
||||||
G_OBJECT_TYPE_NAME (self), self);
|
sd_journal_print (LOG_INFO, "Process %s connected to transaction progress", creds);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user