+ if (thread_status != 0 && thread_status != ESRCH) {
+ ERROR("connectivity plugin: Unable to cancel netlink thread: %d",
+ thread_status);
+ thread_status = -1;
+ } else
+ thread_status = 0;
+ } else {
+ thread_status =
+ pthread_join(connectivity_netlink_thread_id, /* return = */ NULL);
+ if (thread_status != 0 && thread_status != ESRCH) {
+ ERROR("connectivity plugin: Stopping netlink thread failed: %d",
+ thread_status);
+ thread_status = -1;
+ } else
+ thread_status = 0;
+ }
+
+ pthread_mutex_lock(&connectivity_threads_lock);
+ memset(&connectivity_netlink_thread_id, 0,
+ sizeof(connectivity_netlink_thread_id));
+ connectivity_netlink_thread_error = 0;
+ pthread_mutex_unlock(&connectivity_threads_lock);
+
+ DEBUG("connectivity plugin: Finished requesting stop of netlink thread");
+
+ if (socket_status != 0)
+ return socket_status;
+ else
+ return thread_status;
+}
+
+static int stop_dequeue_thread(int shutdown) /* {{{ */
+{
+ pthread_mutex_lock(&connectivity_threads_lock);
+
+ if (connectivity_dequeue_thread_loop == 0) {
+ pthread_mutex_unlock(&connectivity_threads_lock);
+ return -1;
+ }
+
+ // Set thread termination status
+ connectivity_dequeue_thread_loop = 0;
+ pthread_mutex_unlock(&connectivity_threads_lock);
+
+ // Let threads waiting on access to the interface list know to move
+ // on such that they'll see the threads termination status
+ pthread_cond_broadcast(&connectivity_cond);
+
+ int status;
+
+ if (shutdown == 1) {
+ // Calling pthread_cancel here in
+ // the case of a shutdown just assures that the thread is
+ // gone and that the process has been fully terminated.
+
+ DEBUG("connectivity plugin: Canceling dequeue thread for process shutdown");
+
+ status = pthread_cancel(connectivity_dequeue_thread_id);
+
+ if (status != 0 && status != ESRCH) {
+ ERROR("connectivity plugin: Unable to cancel dequeue thread: %d", status);