-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade agent #1368
Closed
Closed
Upgrade agent #1368
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
83c942d
daemon: Load sd unit for callers, log it
cgwalters abac65f
daemon: Add an 'id' param to RegisterClient, log it
cgwalters 912bccf
fixup! daemon: Add an 'id' param to RegisterClient, log it
cgwalters 58cd150
fixup! daemon: Add an 'id' param to RegisterClient, log it
cgwalters 3eabc96
fixup! daemon: Add an 'id' param to RegisterClient, log it
cgwalters File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ | |
#define EXPERIMENTAL_CONFIG_GROUP "Experimental" | ||
|
||
struct RpmOstreeClient; | ||
static struct RpmOstreeClient *client_new (RpmostreedDaemon *self, const char *address); | ||
static struct RpmOstreeClient *client_new (RpmostreedDaemon *self, const char *address, const char *id); | ||
|
||
/** | ||
* SECTION: daemon | ||
|
@@ -98,6 +98,7 @@ G_DEFINE_TYPE_WITH_CODE (RpmostreedDaemon, rpmostreed_daemon, G_TYPE_OBJECT, | |
rpmostreed_daemon_initable_iface_init)) | ||
|
||
struct RpmOstreeClient { | ||
char *id; | ||
char *address; | ||
guint name_watch_id; | ||
/* In Rust this'd be Option<uid_t> etc. */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. RIIR? :) |
||
|
@@ -113,6 +114,7 @@ rpmostree_client_free (struct RpmOstreeClient *client) | |
{ | ||
if (!client) | ||
return; | ||
g_free (client->id); | ||
g_free (client->address); | ||
g_free (client->sd_unit); | ||
g_free (client); | ||
|
@@ -121,10 +123,13 @@ rpmostree_client_free (struct RpmOstreeClient *client) | |
static char * | ||
rpmostree_client_to_string (struct RpmOstreeClient *client) | ||
{ | ||
g_autoptr(GString) buf = g_string_new ("client("); | ||
if (client->id) | ||
g_string_append_printf (buf, "id:%s ", client->id); | ||
/* Since DBus addresses have a leading ':', let's avoid another. Yeah it's not | ||
* symmetric, but it does read better. | ||
*/ | ||
g_autoptr(GString) buf = g_string_new ("client(dbus"); | ||
g_string_append (buf, "dbus"); | ||
g_string_append (buf, client->address); | ||
if (client->sd_unit) | ||
g_string_append_printf (buf, " unit:%s", client->sd_unit); | ||
|
@@ -246,7 +251,7 @@ on_active_txn_changed (GObject *object, | |
* then let's gather the relevant client info now. | ||
*/ | ||
if (!clientdata) | ||
clientdata = clientdata_owned = client_new (self, sender); | ||
clientdata = clientdata_owned = client_new (self, sender, NULL); | ||
g_autofree char *client_str = rpmostree_client_to_string (clientdata); | ||
g_autofree char *client_data_msg = NULL; | ||
if (clientdata->uid_valid) | ||
|
@@ -665,10 +670,12 @@ get_client_pid (RpmostreedDaemon *self, | |
|
||
/* Given a DBus address, load metadata for it */ | ||
static struct RpmOstreeClient * | ||
client_new (RpmostreedDaemon *self, const char *address) | ||
client_new (RpmostreedDaemon *self, const char *address, | ||
const char *client_id) | ||
{ | ||
struct RpmOstreeClient *client = g_new0 (struct RpmOstreeClient, 1); | ||
client->address = g_strdup (address); | ||
client->id = g_strdup (client_id); | ||
if (rpmostreed_get_client_uid (self, address, &client->uid)) | ||
client->uid_valid = TRUE; | ||
if (get_client_pid (self, address, &client->pid)) | ||
|
@@ -685,12 +692,13 @@ client_new (RpmostreedDaemon *self, const char *address) | |
|
||
void | ||
rpmostreed_daemon_add_client (RpmostreedDaemon *self, | ||
const char *client) | ||
const char *client, | ||
const char *client_id) | ||
{ | ||
if (g_hash_table_lookup (self->bus_clients, client)) | ||
return; | ||
|
||
struct RpmOstreeClient *clientdata = client_new (self, client); | ||
struct RpmOstreeClient *clientdata = client_new (self, client, client_id); | ||
clientdata->name_watch_id = | ||
g_dbus_connection_signal_subscribe (self->connection, | ||
"org.freedesktop.DBus", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/name/id/
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I noticed that in self-review, had already pushed a fixup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh right, sigh. I tend to do reviews by looking at each commit one at a time, and I missed the fixup! WDYT if in general we just squash fixups into the commits as long as the PR hasn't been reviewed? Fixups are really helpful for follow-up reviews, but demand extra processing for initial reviews.