diff --git a/ChangeLog b/ChangeLog index ff3ed82cc..c3e07bfa1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2005-06-18 Ray Strode + + * src/nm-netlink-monitor.c + (nm_netlink_monitor_event_handler): check for the presence + of either error condition not both. + + (nm_netlink_monitor_error_handler): emit error signal if + error occurs. + + (nm_netlink_monitor_event_handler), + (nm_netlink_monitor_error_handler), + (nm_netlink_monitor_disconnect_handler): if an + assertion fails disconnect the event handler to prevent + infinite loops. + + * src/nm-netlink-monitor.h: add new error condition + NM_NETLINK_MONITOR_ERROR_WAITING_FOR_SOCKET_DATA + 2005-06-18 Ray Strode * src/nm-netlink-monitor.c diff --git a/src/nm-netlink-monitor.c b/src/nm-netlink-monitor.c index 938938046..9e4b8d6db 100644 --- a/src/nm-netlink-monitor.c +++ b/src/nm-netlink-monitor.c @@ -576,14 +576,14 @@ nm_netlink_monitor_event_handler (GIOChannel *channel, guint num_bytes_to_process; struct nlmsghdr *header; - if (io_condition == NM_NETLINK_MONITOR_ERROR_CONDITIONS) + if (io_condition & NM_NETLINK_MONITOR_ERROR_CONDITIONS) return nm_netlink_monitor_error_handler (channel, io_condition, monitor); - else if (io_condition == NM_NETLINK_MONITOR_DISCONNECT_CONDITIONS) + else if (io_condition & NM_NETLINK_MONITOR_DISCONNECT_CONDITIONS) return nm_netlink_monitor_disconnect_handler (channel, io_condition, monitor); g_return_val_if_fail (!(io_condition & ~(NM_NETLINK_MONITOR_EVENT_CONDITIONS)), - TRUE); + FALSE); error = NULL; @@ -712,7 +712,7 @@ nm_netlink_monitor_event_handler (GIOChannel *channel, g_free (interface_name); } } - g_free(received_bytes); + g_free (received_bytes); return TRUE; } @@ -722,9 +722,20 @@ nm_netlink_monitor_error_handler (GIOChannel *channel, GIOCondition io_condition, NmNetlinkMonitor *monitor) { + GError *socket_error; + g_return_val_if_fail (!(io_condition & ~(NM_NETLINK_MONITOR_ERROR_CONDITIONS)), - TRUE); + FALSE); + + socket_error = + g_error_new (NM_NETLINK_MONITOR_ERROR, + NM_NETLINK_MONITOR_ERROR_WAITING_FOR_SOCKET_DATA, + _("error occured while waiting for data on socket")); + + g_signal_emit (G_OBJECT (monitor), + nm_netlink_monitor_signals[ERROR], + 0, socket_error); return TRUE; } @@ -736,6 +747,6 @@ nm_netlink_monitor_disconnect_handler (GIOChannel *channel, g_return_val_if_fail (!(io_condition & ~(NM_NETLINK_MONITOR_DISCONNECT_CONDITIONS)), - TRUE); + FALSE); return FALSE; } diff --git a/src/nm-netlink-monitor.h b/src/nm-netlink-monitor.h index 129e12357..4939e5307 100644 --- a/src/nm-netlink-monitor.h +++ b/src/nm-netlink-monitor.h @@ -68,6 +68,7 @@ enum _NmNetlinkMonitorError NM_NETLINK_MONITOR_ERROR_BINDING_TO_SOCKET, NM_NETLINK_MONITOR_ERROR_BAD_SENDER, NM_NETLINK_MONITOR_ERROR_BAD_SOCKET_DATA, + NM_NETLINK_MONITOR_ERROR_WAITING_FOR_SOCKET_DATA, NM_NETLINK_MONITOR_ERROR_READING_FROM_SOCKET, NM_NETLINK_MONITOR_ERROR_SENDING_TO_SOCKET };