diff options
author | Thomas Haller <thaller@redhat.com> | 2021-06-24 11:42:34 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-06-28 13:31:35 +0200 |
commit | 34f48a33f3e673f85d06c3d10be4f36d5eb10050 (patch) | |
tree | 3dc4ca7b71fd502adb6059379cf4c36a52a7ad39 | |
parent | 70e5d8e5bd3ec2590a5035554f71b48846961ad9 (diff) | |
download | NetworkManager-34f48a33f3e673f85d06c3d10be4f36d5eb10050.tar.gz |
glib-aux: add nm_g_unix_fd_add_source() helper
-rw-r--r-- | src/libnm-glib-aux/nm-shared-utils.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libnm-glib-aux/nm-shared-utils.h b/src/libnm-glib-aux/nm-shared-utils.h index c73110f6c3..49de9e12b9 100644 --- a/src/libnm-glib-aux/nm-shared-utils.h +++ b/src/libnm-glib-aux/nm-shared-utils.h @@ -1770,6 +1770,20 @@ nm_g_timeout_add_source_approx(guint timeout_msec, return nm_g_source_attach(source, NULL); } +static inline GSource * +nm_g_unix_fd_add_source(int fd, + GIOCondition condition, + GUnixFDSourceFunc function, + gpointer user_data) +{ + /* A convenience function to attach a new unix-fd source to the default GMainContext. + * In that sense it's very similar to g_unix_fd_add() except that it returns a + * reference to the new source. */ + return nm_g_source_attach( + nm_g_unix_fd_source_new(fd, condition, G_PRIORITY_DEFAULT, function, user_data, NULL), + NULL); +} + NM_AUTO_DEFINE_FCN0(GMainContext *, _nm_auto_unref_gmaincontext, g_main_context_unref); #define nm_auto_unref_gmaincontext nm_auto(_nm_auto_unref_gmaincontext) |