summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-01-01 10:07:50 +0100
committerThomas Haller <thaller@redhat.com>2020-01-13 15:46:04 +0100
commit421256073b023d0509d02acb28275e0f3164f662 (patch)
treef670d0bfdfef73b3df0affb6fd4ec1d992f415ca
parent4972ba0957711fa29cc1877548746d2cd54067c2 (diff)
downloadNetworkManager-421256073b023d0509d02acb28275e0f3164f662.tar.gz
shared: add nm_g_unix_fd_source_new() helper
-rw-r--r--shared/nm-glib-aux/nm-shared-utils.c20
-rw-r--r--shared/nm-glib-aux/nm-shared-utils.h9
2 files changed, 28 insertions, 1 deletions
diff --git a/shared/nm-glib-aux/nm-shared-utils.c b/shared/nm-glib-aux/nm-shared-utils.c
index d7581f9a65..3207d8edf9 100644
--- a/shared/nm-glib-aux/nm-shared-utils.c
+++ b/shared/nm-glib-aux/nm-shared-utils.c
@@ -3623,6 +3623,26 @@ nm_g_unix_signal_source_new (int signum,
return source;
}
+GSource *
+nm_g_unix_fd_source_new (int fd,
+ GIOCondition io_condition,
+ int priority,
+ gboolean (*source_func) (int fd,
+ GIOCondition condition,
+ gpointer user_data),
+ gpointer user_data,
+ GDestroyNotify destroy_notify)
+{
+ GSource *source;
+
+ source = g_unix_fd_source_new (fd, io_condition);
+
+ if (priority != G_PRIORITY_DEFAULT)
+ g_source_set_priority (source, priority);
+ g_source_set_callback (source, G_SOURCE_FUNC (source_func), user_data, destroy_notify);
+ return source;
+}
+
/*****************************************************************************/
#define _CTX_LOG(fmt, ...) \
diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h
index 0af58c4b6d..55d992a9e2 100644
--- a/shared/nm-glib-aux/nm-shared-utils.h
+++ b/shared/nm-glib-aux/nm-shared-utils.h
@@ -983,7 +983,14 @@ GSource *nm_g_timeout_source_new (guint timeout_msec,
GSourceFunc func,
gpointer user_data,
GDestroyNotify destroy_notify);
-
+GSource *nm_g_unix_fd_source_new (int fd,
+ GIOCondition io_condition,
+ int priority,
+ gboolean (*source_func) (int fd,
+ GIOCondition condition,
+ gpointer user_data),
+ gpointer user_data,
+ GDestroyNotify destroy_notify);
GSource *nm_g_unix_signal_source_new (int signum,
int priority,
GSourceFunc handler,