static void up_handler(state_t s, event_t e, unmarsh_t abv) { endpt_id_t origin ; unmarsh_endpt_id(abv, &origin) ; if (s->partition) { sys_abort() ; } else { etime_t delay ; if (!distrib(s, &delay)) { up_free(e, abv) ; } else { etime_t when = time_add(alarm_gettime(s->alarm), delay) ; item_t item = record_create(item_t, item) ; /*eprintf("type=%s\n", event_type_to_string(event_type(e))) ;*/ item->type = DROP_UP ; item->u.up.event = e ; item->u.up.abv = abv ; priq_add(s->priq, when, item) ; dnnm(s, event_timer_time(when)) ; } } }
static int sunxi_rtc_getalarm(struct device *dev, struct rtc_wkalrm *alrm) { struct platform_device *pdev = to_platform_device(dev); struct sunxi_rtc *rtc_dev = platform_get_drvdata(pdev); int ret = 0; int reg_val = 0; mutex_lock(&rtc_dev->mutex); /* get alarm time */ if (alarm_gettime(rtc_dev, &alrm->time)) { pr_err("%s(%d) err: get alarm time failed!\n", __func__, __LINE__); ret = -EINVAL; goto end; } reg_val = rtc_read_reg(rtc_dev->ac100, ALM_INT_ENA_OFF); if (reg_val & 0x1) alrm->enabled = 1; end: mutex_unlock(&rtc_dev->mutex); return ret; }
static void upnm_handler(state_t s, event_t e) { switch(event_type(e)) { case EVENT_FAIL: assert(bool_array_super(event_failures(e), s->failed, s->vs->nmembers)) ; bool_array_copy_into(s->failed, event_failures(e), s->vs->nmembers) ; upnm(s, e) ; break ; case EVENT_INIT: dnnm(s, event_timer_time(time_zero())) ; upnm(s, e) ; break ; case EVENT_TIMER: { etime_t time = event_time(e) ; item_t item ; while (priq_get_upto(s->priq, time, NULL, (void**)&item)) { s->acct_delivered ++ ; switch(item->type) { case DROP_UP: { rank_t origin = event_peer(item->u.up.event) ; if (origin >= 0 && array_get(s->failed, origin)) { up_free(item->u.up.event, item->u.up.abv) ; } else { up(s, item->u.up.event, item->u.up.abv) ; } } break ; case DROP_UPNM: upnm(s, item->u.upnm.event) ; break ; OTHERWISE_ABORT() ; } record_free(item) ; } if (time_ge(time, s->next_sweep)) { if (!time_is_zero(s->next_sweep) && sys_random(5) == 1) { rank_t i ; bool_array_t suspects = bool_array_create_init(s->vs->nmembers, FALSE) ; for(i=0;i<s->vs->nmembers;i++) { if (i == s->ls->rank) { continue ; } if (sys_random(4) == 0) { array_set(suspects, i, TRUE) ; } } if (bool_array_exists(suspects, s->vs->nmembers)) { dnnm(s, event_suspect_reason_create(suspects, name)) ; } else { array_free(suspects) ; } } #if 0 /* Suspicions are randomly generated every 0-8 seconds. */ s->next_sweep = time_add(time, time_of_usecs(sys_random(1<<23/*8M*/))) ; #else s->next_sweep = time_add(time, time_of_usecs(sys_random(1<<20/*1M*/))) ; #endif dnnm(s, event_timer_time(s->next_sweep)) ; /* request next sweep */ } upnm(s, e) ; } break ; case EVENT_GOSSIP_EXT: { /*endpt_id_t origin = NULL ;*/ etime_t delay ; /* let origin = getExtender (function | HealGos(_,(_,endpt),_,_) -> Some (Some endpt) | SwitchGos(_,(_,endpt),_) -> Some (Some endpt) | _ -> None ) None ev in */ if (1 /*!origin*/) { upnm(s, e) ; } else if (s->partition) { sys_abort() ; } else if (!distrib(s, &delay)) { event_free(e) ; } else { /* Deliver after a certain delay.... */ etime_t when = time_add(alarm_gettime(s->alarm), delay) ; item_t item = record_create(item_t, item) ; item->type = DROP_UPNM ; item->u.upnm.event = e ; priq_add(s->priq, when, item) ; dnnm(s, event_timer_time(when)) ; } } break ; case EVENT_ACCOUNT: log(("delivered=%d dropped=%d", s->acct_delivered, s->acct_dropped)) ; upnm(s, e) ; break ; EVENT_DUMP_HANDLE() ; default: upnm(s, e) ; break ; } }