void process_stop(Process* proc) { MAGIC_ASSERT(proc); /* we only have state if we are running */ if(process_isRunning(proc)) { info("stopping '%s' process", g_quark_to_string(proc->programID)); program_swapInState(proc->prog, proc->state); thread_execute(proc->mainThread, program_getFreeFunc(proc->prog)); debug("calling atexit for '%s' process", g_quark_to_string(proc->programID)); while(proc->atExitFunctions && g_queue_get_length(proc->atExitFunctions) > 0) { ProcessExitCallbackData* exitCallback = g_queue_pop_head(proc->atExitFunctions); if(exitCallback->passArgument) { thread_executeExitCallback(proc->mainThread, exitCallback->callback, exitCallback->argument); } else { thread_execute(proc->mainThread, (PluginNotifyFunc)exitCallback->callback); } g_free(exitCallback); } program_swapOutState(proc->prog, proc->state); /* free our copy of plug-in resources, and other application state */ program_freeState(proc->prog, proc->state); proc->state = NULL; thread_stop(proc->mainThread); thread_unref(proc->mainThread); proc->mainThread = NULL; } }
/** * @fn eigrp_update_send_GR_thread * * @param[in] thread contains neighbor who would receive Graceful restart * * @return int always 0 * * @par * Function used for sending Graceful restart Update packet * in thread, it is prepared for multiple chunks of packet. * * Uses nbr_gr_packet_type and t_nbr_send_gr from neighbor. */ int eigrp_update_send_GR_thread(struct thread *thread) { struct eigrp_neighbor *nbr; /* get argument from thread */ nbr = THREAD_ARG(thread); /* remove this thread pointer */ nbr->t_nbr_send_gr = NULL; /* if there is packet waiting in queue, * schedule this thread again with small delay */ if(nbr->retrans_queue->count > 0) { nbr->t_nbr_send_gr = thread_add_timer_msec(master, eigrp_update_send_GR_thread, nbr, 10); return 0; } /* send GR EIGRP packet chunk */ eigrp_update_send_GR_part(nbr); /* if it wasn't last chunk, schedule this thread again */ if(nbr->nbr_gr_packet_type != EIGRP_PACKET_PART_LAST) nbr->t_nbr_send_gr = thread_execute(master, eigrp_update_send_GR_thread, nbr, 0); return 0; }
int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx, action_func2* func2, main_func *mainfunc, void *arg, int *ret, int job_count) { SliceThreadContext *c = avctx->internal->thread_ctx; c->func2 = func2; c->mainfunc = mainfunc; return thread_execute(avctx, NULL, arg, ret, job_count, 0); }
void process_notify(Process* proc, Thread* thread) { MAGIC_ASSERT(proc); /* only notify if we are running */ if(process_isRunning(proc)) { program_swapInState(proc->prog, proc->state); thread_execute(thread, program_getNotifyFunc(proc->prog)); program_swapOutState(proc->prog, proc->state); } }
void thread_list_execute (struct thread_master *master, struct thread_list *list) { struct thread *thread; thread = thread_trim_head (list); if (thread != NULL) { thread_execute (master, thread->func, thread->arg, thread->u.val); thread->type = THREAD_UNUSED; thread_add_unuse (master, thread); } }
/** * @fn eigrp_update_send_GR * * @param[in] nbr Neighbor who would receive Graceful restart * @param[in] gr_type Who executed Graceful restart * @param[in] vty Virtual terminal for log output * * @return void * * @par * Function used for sending Graceful restart Update packet: * Creates Update packet with INIT, RS, EOT flags and include * all route except those filtered */ void eigrp_update_send_GR (struct eigrp_neighbor *nbr, enum GR_type gr_type, struct vty *vty) { struct eigrp_prefix_entry *pe2; struct listnode *node2, *nnode2; struct list *prefixes; if(gr_type == EIGRP_GR_FILTER) { /* function was called after applying filtration */ zlog_info("Neighbor %s (%s) is resync: route configuration changed", inet_ntoa(nbr->src), ifindex2ifname(nbr->ei->ifp->ifindex)); } else if(gr_type == EIGRP_GR_MANUAL) { /* Graceful restart was called manually */ zlog_info("Neighbor %s (%s) is resync: manually cleared", inet_ntoa(nbr->src), ifindex2ifname(nbr->ei->ifp->ifindex)); if(vty != NULL) { vty_time_print (vty, 0); vty_out (vty, "Neighbor %s (%s) is resync: manually cleared%s", inet_ntoa (nbr->src), ifindex2ifname (nbr->ei->ifp->ifindex), VTY_NEWLINE); } } prefixes = list_new(); /* add all prefixes from topology table to list */ for (ALL_LIST_ELEMENTS(nbr->ei->eigrp->topology_table, node2, nnode2, pe2)) { listnode_add(prefixes, pe2); } /* save prefixes to neighbor */ nbr->nbr_gr_prefixes_send = prefixes; /* indicate, that this is first GR Update packet chunk */ nbr->nbr_gr_packet_type = EIGRP_PACKET_PART_FIRST; /* execute packet sending in thread */ nbr->t_nbr_send_gr = thread_execute(master, eigrp_update_send_GR_thread, nbr, 0); }
void ospf6_interface_if_del (struct interface *ifp) { struct ospf6_interface *oi; oi = (struct ospf6_interface *) ifp->info; if (oi == NULL) return; /* interface stop */ if (oi->area) thread_execute (master, interface_down, oi, 0); listnode_delete (oi->area->if_list, oi); oi->area = (struct ospf6_area *) NULL; /* cut link */ oi->interface = NULL; ifp->info = NULL; ospf6_interface_delete (oi); }
static int thread_execute2(AVCodecContext *avctx, action_func2* func2, void *arg, int *ret, int job_count) { SliceThreadContext *c = avctx->internal->thread_ctx; c->func2 = func2; return thread_execute(avctx, NULL, arg, ret, job_count, 0); }