mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-04 02:28:02 +02:00
all: use nm_{idle,timeout}_add_source() instead of g_source_attach()
This commit is contained in:
parent
34f48a33f3
commit
61d2af3518
8 changed files with 25 additions and 80 deletions
|
|
@ -182,25 +182,18 @@ _connect_open_tty(NMBluez5DunContext *context)
|
|||
nm_strerror_native(errsv),
|
||||
errsv);
|
||||
context->cdat->connect_open_tty_started_at = nm_utils_get_monotonic_timestamp_nsec();
|
||||
context->cdat->source = nm_g_timeout_source_new(100,
|
||||
G_PRIORITY_DEFAULT,
|
||||
_connect_open_tty_retry_cb,
|
||||
context,
|
||||
NULL);
|
||||
g_source_attach(context->cdat->source, NULL);
|
||||
context->cdat->source =
|
||||
nm_g_timeout_add_source(100, _connect_open_tty_retry_cb, context);
|
||||
}
|
||||
return -errsv;
|
||||
}
|
||||
|
||||
context->rfcomm_tty_fd = fd;
|
||||
|
||||
context->rfcomm_tty_poll_source = nm_g_unix_fd_source_new(context->rfcomm_tty_fd,
|
||||
context->rfcomm_tty_poll_source = nm_g_unix_fd_add_source(context->rfcomm_tty_fd,
|
||||
G_IO_ERR | G_IO_HUP,
|
||||
G_PRIORITY_DEFAULT,
|
||||
_rfcomm_tty_poll_cb,
|
||||
context,
|
||||
NULL);
|
||||
g_source_attach(context->rfcomm_tty_poll_source, NULL);
|
||||
context);
|
||||
|
||||
_context_invoke_callback_success(context);
|
||||
return 0;
|
||||
|
|
@ -369,13 +362,10 @@ _connect_socket_connect(NMBluez5DunContext *context)
|
|||
context->dst_str,
|
||||
context->rfcomm_channel);
|
||||
|
||||
context->cdat->source = nm_g_unix_fd_source_new(context->rfcomm_sock_fd,
|
||||
context->cdat->source = nm_g_unix_fd_add_source(context->rfcomm_sock_fd,
|
||||
G_IO_OUT,
|
||||
G_PRIORITY_DEFAULT,
|
||||
_connect_socket_connect_cb,
|
||||
context,
|
||||
NULL);
|
||||
g_source_attach(context->cdat->source, NULL);
|
||||
context);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -567,12 +557,8 @@ _connect_sdp_io_cb(int fd, GIOCondition condition, gpointer user_data)
|
|||
nm_strerror_native(errsv),
|
||||
errsv);
|
||||
nm_clear_g_source_inst(&context->cdat->source);
|
||||
context->cdat->source = nm_g_timeout_source_new(1000,
|
||||
G_PRIORITY_DEFAULT,
|
||||
_connect_sdp_session_start_on_idle_cb,
|
||||
context,
|
||||
NULL);
|
||||
g_source_attach(context->cdat->source, NULL);
|
||||
context->cdat->source =
|
||||
nm_g_timeout_add_source(1000, _connect_sdp_session_start_on_idle_cb, context);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
|
|
@ -616,13 +602,10 @@ _connect_sdp_io_cb(int fd, GIOCondition condition, gpointer user_data)
|
|||
}
|
||||
|
||||
/* Set callback responsible for update the internal SDP transaction */
|
||||
context->cdat->source = nm_g_unix_fd_source_new(fd,
|
||||
context->cdat->source = nm_g_unix_fd_add_source(fd,
|
||||
G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
|
||||
G_PRIORITY_DEFAULT,
|
||||
_connect_sdp_search_io_cb,
|
||||
context,
|
||||
NULL);
|
||||
g_source_attach(context->cdat->source, NULL);
|
||||
context);
|
||||
|
||||
done:
|
||||
if (error)
|
||||
|
|
@ -664,13 +647,10 @@ _connect_sdp_session_start(NMBluez5DunContext *context, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
context->cdat->source = nm_g_unix_fd_source_new(sdp_get_socket(context->cdat->sdp_session),
|
||||
context->cdat->source = nm_g_unix_fd_add_source(sdp_get_socket(context->cdat->sdp_session),
|
||||
G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
|
||||
G_PRIORITY_DEFAULT,
|
||||
_connect_sdp_io_cb,
|
||||
context,
|
||||
NULL);
|
||||
g_source_attach(context->cdat->source, NULL);
|
||||
context);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -347,9 +347,7 @@ nm_acd_manager_start_probe(NMAcdManager *self, guint timeout)
|
|||
|
||||
nm_assert(!self->event_source);
|
||||
n_acd_get_fd(self->acd, &fd);
|
||||
self->event_source =
|
||||
nm_g_unix_fd_source_new(fd, G_IO_IN, G_PRIORITY_DEFAULT, acd_event, self, NULL);
|
||||
g_source_attach(self->event_source, NULL);
|
||||
self->event_source = nm_g_unix_fd_add_source(fd, G_IO_IN, acd_event, self);
|
||||
|
||||
return success ? 0 : -NME_UNSPEC;
|
||||
}
|
||||
|
|
@ -434,9 +432,7 @@ nm_acd_manager_announce_addresses(NMAcdManager *self)
|
|||
|
||||
if (!self->event_source) {
|
||||
n_acd_get_fd(self->acd, &fd);
|
||||
self->event_source =
|
||||
nm_g_unix_fd_source_new(fd, G_IO_IN, G_PRIORITY_DEFAULT, acd_event, self, NULL);
|
||||
g_source_attach(self->event_source, NULL);
|
||||
self->event_source = nm_g_unix_fd_add_source(fd, G_IO_IN, acd_event, self);
|
||||
}
|
||||
|
||||
return success ? 0 : -NME_UNSPEC;
|
||||
|
|
|
|||
|
|
@ -1673,12 +1673,7 @@ _scan_supplicant_request_scan_cb(NMSupplicantInterface *supp_iface,
|
|||
* Artificially keep the scanning state on, for another SCAN_EXTRA_DELAY_MSEC msec. */
|
||||
nm_clear_g_source_inst(&priv->scan_request_delay_source);
|
||||
priv->scan_request_delay_source =
|
||||
nm_g_source_attach(nm_g_timeout_source_new(SCAN_EXTRA_DELAY_MSEC,
|
||||
G_PRIORITY_DEFAULT,
|
||||
_scan_request_delay_cb,
|
||||
self,
|
||||
NULL),
|
||||
NULL);
|
||||
nm_g_timeout_add_source(SCAN_EXTRA_DELAY_MSEC, _scan_request_delay_cb, self);
|
||||
|
||||
g_clear_object(&priv->scan_request_cancellable);
|
||||
_scan_notify_is_scanning(self);
|
||||
|
|
|
|||
|
|
@ -969,9 +969,7 @@ nettools_create(NMDhcpNettools *self, GError **error)
|
|||
|
||||
n_dhcp4_client_get_fd(priv->client, &fd);
|
||||
|
||||
priv->event_source =
|
||||
nm_g_unix_fd_source_new(fd, G_IO_IN, G_PRIORITY_DEFAULT, dhcp4_event_cb, self, NULL);
|
||||
g_source_attach(priv->event_source, NULL);
|
||||
priv->event_source = nm_g_unix_fd_add_source(fd, G_IO_IN, dhcp4_event_cb, self);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -422,12 +422,7 @@ ensure_resolved_running(NMDnsSystemdResolved *self)
|
|||
priv->try_start_blocked = TRUE;
|
||||
|
||||
priv->try_start_timeout_source =
|
||||
nm_g_source_attach(nm_g_timeout_source_new(4000,
|
||||
G_PRIORITY_DEFAULT,
|
||||
_ensure_resolved_running_timeout,
|
||||
self,
|
||||
NULL),
|
||||
NULL);
|
||||
nm_g_timeout_add_source(4000, _ensure_resolved_running_timeout, self);
|
||||
|
||||
nm_dbus_connection_call_start_service_by_name(priv->dbus_connection,
|
||||
SYSTEMD_RESOLVED_DBUS_SERVICE,
|
||||
|
|
@ -821,19 +816,13 @@ _resolve_start(NMDnsSystemdResolved *self, NMDnsSystemdResolvedResolveHandle *ha
|
|||
_LOG2T(handle, "systemd-resolved not running. Failing on idle...");
|
||||
nm_assert(!handle->timeout_source);
|
||||
handle->is_failing_on_idle = TRUE;
|
||||
handle->timeout_source = nm_g_source_attach(
|
||||
nm_g_idle_source_new(G_PRIORITY_DEFAULT, _resolve_failing_on_idle, handle, NULL),
|
||||
NULL);
|
||||
handle->timeout_source = nm_g_idle_add_source(_resolve_failing_on_idle, handle);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!handle->timeout_source) {
|
||||
handle->timeout_source = nm_g_source_attach(nm_g_timeout_source_new(handle->timeout_msec,
|
||||
G_PRIORITY_DEFAULT,
|
||||
_resolve_handle_timeout,
|
||||
handle,
|
||||
NULL),
|
||||
NULL);
|
||||
handle->timeout_source =
|
||||
nm_g_timeout_add_source(handle->timeout_msec, _resolve_handle_timeout, handle);
|
||||
}
|
||||
|
||||
if (is_running == NM_TERNARY_DEFAULT) {
|
||||
|
|
|
|||
|
|
@ -599,9 +599,7 @@ start(NMNDisc *ndisc)
|
|||
|
||||
fd = ndp_get_eventfd(priv->ndp);
|
||||
|
||||
priv->event_source =
|
||||
nm_g_unix_fd_source_new(fd, G_IO_IN, G_PRIORITY_DEFAULT, event_ready, ndisc, NULL);
|
||||
g_source_attach(priv->event_source, NULL);
|
||||
priv->event_source = nm_g_unix_fd_add_source(fd, G_IO_IN, event_ready, ndisc);
|
||||
|
||||
/* Flush any pending messages to avoid using obsolete information */
|
||||
event_ready(fd, 0, ndisc);
|
||||
|
|
|
|||
|
|
@ -124,12 +124,8 @@ _cancellable_idle_cb(gpointer user_data)
|
|||
static void
|
||||
_cancellable_on_idle(NMAuthChain *self)
|
||||
{
|
||||
if (self->cancellable_idle_source)
|
||||
return;
|
||||
|
||||
self->cancellable_idle_source =
|
||||
nm_g_idle_source_new(G_PRIORITY_DEFAULT, _cancellable_idle_cb, self, NULL);
|
||||
g_source_attach(self->cancellable_idle_source, NULL);
|
||||
if (!self->cancellable_idle_source)
|
||||
self->cancellable_idle_source = nm_g_idle_add_source(_cancellable_idle_cb, self);
|
||||
}
|
||||
|
||||
GCancellable *
|
||||
|
|
|
|||
|
|
@ -508,15 +508,8 @@ multi_socket_cb(CURL *e_handle, curl_socket_t fd, int what, void *userdata, void
|
|||
else
|
||||
condition = 0;
|
||||
|
||||
if (condition) {
|
||||
fdp->source = nm_g_unix_fd_source_new(fd,
|
||||
condition,
|
||||
G_PRIORITY_DEFAULT,
|
||||
_con_curl_socketevent_cb,
|
||||
fdp,
|
||||
NULL);
|
||||
g_source_attach(fdp->source, NULL);
|
||||
}
|
||||
if (condition)
|
||||
fdp->source = nm_g_unix_fd_add_source(fd, condition, _con_curl_socketevent_cb, fdp);
|
||||
}
|
||||
|
||||
return CURLM_OK;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue