void rt_table_delete(u_int32_t dest_addr) { rt_table_t *rt_entry, *prev; hash_value hash; unsigned int index; /* Calculate index */ index = hashing(&dest_addr, &hash); for (prev = NULL, rt_entry = routing_table[index]; rt_entry != NULL; prev = rt_entry, rt_entry = rt_entry->next) { if (rt_entry->hash != hash) continue; if (memcmp(&dest_addr, &rt_entry->dest_addr, sizeof(u_int32_t)) == 0) { if (prev == NULL) routing_table[index] = rt_entry->next; else prev->next = rt_entry->next; precursor_list_destroy(rt_entry); if (rt_entry->hcnt != INFTY) k_del_rte(dest_addr, 0, 0); /* Make sure any timers are removed... */ timer_remove(&rt_entry->rt_timer); timer_remove(&rt_entry->hello_timer); timer_remove(&rt_entry->ack_timer); free(rt_entry); return; } } }
/* Route expiry and Deletion, AODV draft v.9, section 8.13. */ int rt_table_invalidate(rt_table_t * rt_entry) { #ifdef DEBUG struct timeval now; gettimeofday(&now, NULL); #endif if (rt_entry == NULL) return -1; #ifdef DEBUG if(rt_entry->hello_timer.used) log(LOG_DEBUG, 0, "route_expire_timeout: last HELLO: %ld", timeval_diff(&now, &rt_entry->last_hello_time) / 1000); #endif timer_remove(&rt_entry->rt_timer); timer_remove(&rt_entry->hello_timer); timer_remove(&rt_entry->ack_timer); /* Save last hopcount */ rt_entry->last_hcnt = rt_entry->hcnt; /* Set infinity hop count */ rt_entry->hcnt = INFTY; /* When the lifetime of a route entry expires, increase the sequence number for that entry. (AODV draft v.10, section 6.1.) */ rt_entry->dest_seqno++; rt_entry->flags = 0; rt_entry->last_life = 0; if (rt_entry->last_hcnt == 1) rt_table_remove_precursor(rt_entry->dest_addr); /* We should delete the precursor list for all unreachable destinations. */ precursor_list_destroy(rt_entry); /* Delete kernel routing table entry. */ k_del_rte(rt_entry->dest_addr, 0, 0); /* Schedule a deletion timer */ rt_entry->rt_timer.handler = route_delete_timeout; timer_add_msec(&rt_entry->rt_timer, DELETE_PERIOD); #ifdef DEBUG log(LOG_DEBUG, 0, "rt_table_invalidate: %s removed in %u msecs", ip_to_str(rt_entry->dest_addr), DELETE_PERIOD); #endif return 0; }
/* Stop and free download. */ void as_download_free (ASDownload *dl) { List *l; if (!dl) return; /* Cancel all active connections. */ stop_all_connections (dl); /* Make sure any source search is gone */ if (dl->search) as_searchman_remove (AS->searchman, dl->search); as_hash_free (dl->hash); free (dl->path); if (dl->fp) fclose (dl->fp); for (l = dl->conns; l; l = l->next) as_downconn_free (l->data); list_free (dl->conns); for (l = dl->chunks; l; l = l->next) as_downchunk_free (l->data); list_free (dl->chunks); timer_remove (dl->maintenance_timer); as_meta_free (dl->meta); free (dl); }
void digdug_customio_w(int offset,int data) { if (errorlog && data != 0x10 && data != 0x71) fprintf(errorlog,"%04x: custom IO command %02x\n",cpu_get_pc(),data); customio_command = data; switch (data) { case 0x10: if (nmi_timer) timer_remove (nmi_timer); nmi_timer = 0; return; case 0xa1: /* go into switch mode */ mode = 1; break; case 0xc1: case 0xe1: /* go into credit mode */ mode = 0; break; case 0xb1: /* status? */ credits = 0; /* this is a good time to reset the credits counter */ break; } nmi_timer = timer_pulse (TIME_IN_USEC (50), 0, digdug_nmi_generate); }
/**************************************************************************** ** ** ** Name: timer_stop() ** ** ** ** Description: Stop the timer with the specified identifier ** ** ** ** Inputs: id: The identifier of the timer to be stopped ** ** Others: None ** ** ** ** Outputs: None ** ** Return: NAS_TIMER_INACTIVE_ID when successfully stop- ** ** ped; The timer identifier otherwise. ** ** Others: None ** ** ** ***************************************************************************/ int nas_timer_stop ( int id) { /* * Check if the timer entry is active */ if (_nas_timer_db_is_active (id)) { nas_timer_entry_t *entry; /* * Remove the entry from the timer queue */ entry = _nas_timer_db_remove_entry (id); #if ENABLE_ITTI timer_remove (entry->timer_id); #else (void)entry; #endif /* * Delete the timer entry */ _nas_timer_db_delete_entry (id); return (NAS_TIMER_INACTIVE_ID); } return (id); }
static STATE_POSTLOAD( timer_postload ) { emu_timer *privlist = NULL; emu_timer *t; /* remove all timers and make a private list */ while (timer_head != NULL) { t = timer_head; /* temporary timers go away entirely */ if (t->temporary) timer_remove(t); /* permanent ones get added to our private list */ else { timer_list_remove(t); t->next = privlist; privlist = t; } } /* now add them all back in; this effectively re-sorts them by time */ while (privlist != NULL) { t = privlist; privlist = t->next; timer_list_insert(t); } }
static inline void op_metro_unset_timer(op_metro_t* metro) { timer_remove(&(metro->timer)); // timers_unset_custom(&(metro->timer)); // print_dbg("\r\n op_metro remove timer, return value: "); // print_dbg(ret ? "1" : "0"); }
int wave_status(int id, int newstatus) { /* wave status has the following bitfields: * * Bit 1: Mute (1=mute 0=nomute) * Bit 0: Motor (1=on 0=off) * * Also, you can pass -1 to have it simply return the status */ struct wave_file *w = &wave[id]; if( !w->file ) return 0; if( newstatus != -1 ) { w->mute = newstatus & 2; newstatus &= 1; if( newstatus && !w->timer ) { w->timer = timer_set(TIME_NEVER, 0, NULL); } else if( !newstatus && w->timer ) { if( w->timer ) w->offset += (((float)timer_timeelapsed(w->timer))/(float)TIME_ONE_SEC) * w->smpfreq; timer_remove(w->timer); w->timer = NULL; bitmap_dirty = 1; } } return (w->timer ? 1 : 0) | (w->mute ? 2 : 0); }
int wave_seek(int id, int offset, int whence) { struct wave_file *w = &wave[id]; UINT32 pos = 0; if( !w->file ) return pos; switch( whence ) { case SEEK_SET: w->offset = offset; break; case SEEK_END: w->offset = w->samples - 1; break; case SEEK_CUR: if( w->timer ) pos = w->offset + ((((float)timer_timeelapsed(w->timer))/(float)TIME_ONE_SEC) * w->smpfreq); w->offset = pos + offset; if( w->offset < 0 ) w->offset = 0; if( w->offset >= w->length ) w->offset = w->length - 1; } w->playpos = w->offset; if( w->timer ) { timer_remove(w->timer); w->timer = timer_set(TIME_NEVER, 0, NULL); } return w->offset; }
/* TimerHandler from fm.c */ static void TimerHandler(int n,int c,int count,double stepTime) { if( count == 0 ) { /* Reset FM Timer */ if( Timer[n][c] ) { // if(errorlog) fprintf(errorlog,"2612 TimerReset %d\n",c); timer_remove (Timer[n][c]); Timer[n][c] = 0; } } else { /* Start FM Timer */ double timeSec = (double)count * stepTime; if( Timer[n][c] == 0 ) { double slack; slack = timer_get_time() - lastfired[n][c]; /* hackish way to make bstars intro sync without */ /* breaking sonicwi2 command 0x35 */ if (slack < 0.000050) slack = 0; // if(errorlog) fprintf(errorlog,"2612 TimerSet %d %f slack %f\n",c,timeSec,slack); Timer[n][c] = timer_set (timeSec - slack, (c<<7)|n, timer_callback_2612 ); } } }
int seek_list_remove(u_int32_t dest_addr) { seek_list_t *curr, *prev; curr = seek_list_head; prev = NULL; while (curr != NULL) { if (curr->dest_addr == dest_addr) { if (prev == NULL) seek_list_head = curr->next; else prev->next = curr->next; /* Make sure any timers are removed */ timer_remove(&curr->seek_timer); if (curr->ipd) free(curr->ipd); free(curr); return 1; } prev = curr; curr = curr->next; } return 0; }
void rrep_ack_process(RREP_ack * rrep_ack, int rrep_acklen, u_int32_t ip_src, u_int32_t ip_dst) { rt_table_t *rt_entry; rt_entry = rt_table_find(ip_src); if (rt_entry == NULL) { #ifdef DEBUG log(LOG_WARNING, 0, "rrep_ack_process: No RREP_ACK expected for %s", ip_to_str(ip_src)); #endif return; } #ifdef DEBUG log(LOG_DEBUG, 0, "rrep_ack_process: Received RREP_ACK from %s", ip_to_str(ip_src)); #endif /* Remove unexpired timer for this RREP_ACK */ if (rt_entry->ack_timer.used) timer_remove(&rt_entry->ack_timer); }
static MACHINE_STOP(taito) { if ( TAITOlocals.timer_irq ) { timer_remove(TAITOlocals.timer_irq); TAITOlocals.timer_irq = NULL; } if (core_gameData->hw.soundBoard) sndbrd_0_exit(); }
void pacland_stop_mcu_timer( void ) { if ( pacland_timer ) { timer_remove( pacland_timer ); pacland_timer = 0; } }
static void timer_callback_2151(int param) { int n=param&0x7f; int c=param>>7; timer_remove(Timer[n][c]); Timer[n][c] = 0; YM2151TimerOver(n,c); }
rt_table_t *rt_table_update_timeout(rt_table_t *entry, u_int32_t life) { entry->expire = get_currtime() + life; timer_remove(entry->timer_id); #ifdef DEBUG /* log(LOG_INFO, 0, "rt_table_update(): New timer for %s, life=%d", */ /* ip_to_str(entry->dest), newlife); */ #endif entry->timer_id = timer_new(life, route_expire_timeout, entry); return entry; }
void mame_timer_set_global_time(mame_time newbase) { mame_timer *timer; /* set the new global offset */ global_basetime = newbase; LOG(("mame_timer_set_global_time: new=%.9f head->expire=%.9f\n", mame_time_to_double(newbase), mame_time_to_double(timer_head->expire))); /* now process any timers that are overdue */ while (compare_mame_times(timer_head->expire, global_basetime) <= 0) { int was_enabled = timer_head->enabled; /* if this is a one-shot timer, disable it now */ timer = timer_head; if (compare_mame_times(timer->period, time_zero) == 0 || compare_mame_times(timer->period, time_never) == 0) timer->enabled = 0; /* set the global state of which callback we're in */ callback_timer_modified = 0; callback_timer = timer; callback_timer_expire_time = timer->expire; /* call the callback */ if (was_enabled && timer->callback) { LOG(("Timer %s:%d fired (expire=%.9f)\n", timer->file, timer->line, mame_time_to_double(timer->expire))); profiler_mark(PROFILER_TIMER_CALLBACK); (*timer->callback)(timer->callback_param); profiler_mark(PROFILER_END); } /* clear the callback timer global */ callback_timer = NULL; /* reset or remove the timer, but only if it wasn't modified during the callback */ if (!callback_timer_modified) { /* if the timer is temporary, remove it now */ if (timer->temporary) timer_remove(timer); /* otherwise, reschedule it */ else { timer->start = timer->expire; timer->expire = add_mame_times(timer->expire, timer->period); timer_list_remove(timer); timer_list_insert(timer); } } } }
void NS_CLASS rrep_send(RREP * rrep, rt_table_t * rev_rt, rt_table_t * fwd_rt, int size) { u_int8_t rrep_flags = 0; struct in_addr dest; if (!rev_rt) { DEBUG(LOG_WARNING, 0, "Can't send RREP, rev_rt = NULL!"); return; } dest.s_addr = rrep->dest_addr; /* Check if we should request a RREP-ACK */ if ((rev_rt->state == VALID && rev_rt->flags & RT_UNIDIR) || (rev_rt->hcnt == 1 && unidir_hack)) { rt_table_t *neighbor = rt_table_find(rev_rt->next_hop); if (neighbor && neighbor->state == VALID && !neighbor->ack_timer.used) { /* If the node we received a RREQ for is a neighbor we are probably facing a unidirectional link... Better request a RREP-ack */ rrep_flags |= RREP_ACK; neighbor->flags |= RT_UNIDIR; /* Must remove any pending hello timeouts when we set the RT_UNIDIR flag, else the route may expire after we begin to ignore hellos... */ timer_remove(&neighbor->hello_timer); neighbor_link_break(neighbor); DEBUG(LOG_DEBUG, 0, "Link to %s is unidirectional!", ip_to_str(neighbor->dest_addr)); timer_set_timeout(&neighbor->ack_timer, NEXT_HOP_WAIT); } } DEBUG(LOG_DEBUG, 0, "Sending RREP to next hop %s about %s->%s", ip_to_str(rev_rt->next_hop), ip_to_str(rev_rt->dest_addr), ip_to_str(dest)); aodv_socket_send((AODV_msg *) rrep, rev_rt->next_hop, size, MAXTTL, &DEV_IFINDEX(rev_rt->ifindex)); /* Update precursor lists */ if (fwd_rt) { precursor_add(fwd_rt, rev_rt->next_hop); precursor_add(rev_rt, fwd_rt->next_hop); } if (!llfeedback && optimized_hellos) hello_start(); }
void timer_set_global_time(attotime newbase) { emu_timer *timer; /* set the new global offset */ global_basetime = newbase; LOG(("timer_set_global_time: new=%s head->expire=%s\n", attotime_string(newbase, 9), attotime_string(timer_head->expire, 9))); /* now process any timers that are overdue */ while (attotime_compare(timer_head->expire, global_basetime) <= 0) { int was_enabled = timer_head->enabled; /* if this is a one-shot timer, disable it now */ timer = timer_head; if (attotime_compare(timer->period, attotime_zero) == 0 || attotime_compare(timer->period, attotime_never) == 0) timer->enabled = FALSE; /* set the global state of which callback we're in */ callback_timer_modified = FALSE; callback_timer = timer; callback_timer_expire_time = timer->expire; /* call the callback */ if (was_enabled && timer->callback != NULL) { LOG(("Timer %s:%d[%s] fired (expire=%s)\n", timer->file, timer->line, timer->func, attotime_string(timer->expire, 9))); profiler_mark(PROFILER_TIMER_CALLBACK); (*timer->callback)(Machine, timer->ptr, timer->param); profiler_mark(PROFILER_END); } /* clear the callback timer global */ callback_timer = NULL; /* reset or remove the timer, but only if it wasn't modified during the callback */ if (!callback_timer_modified) { /* if the timer is temporary, remove it now */ if (timer->temporary) timer_remove(timer); /* otherwise, reschedule it */ else { timer->start = timer->expire; timer->expire = attotime_add(timer->expire, timer->period); timer_list_remove(timer); timer_list_insert(timer); } } } }
void TTL74123_unconfig(void) { int i; for (i = 0; i < MAX_TTL74123; i++) { if (chip[i].timer) timer_remove(chip[i].timer); } memset(&chip, 0, sizeof(chip)); }
void rt_table_delete(u_int32_t dest) { rt_table_t *entry, *prev; hash_value hash; unsigned int index; /* Calculate index */ index = hashing(&dest, &hash); entry = routing_table[index]; prev = NULL; for(; entry != NULL; prev = entry, entry = entry->next) { if(entry->hash != hash) continue; if(memcmp(&dest, &entry->dest, sizeof(u_int32_t)) == 0) { if(prev == NULL) routing_table[index] = entry->next; else prev = entry->next; total_entries--; precursor_list_destroy(entry); if(!IS_INFTY(entry->hcnt)) { k_del_rte(dest, 0, 0); /* k_del_arp(entry->dest); */ } /* Make sure any timers are removed... */ if(entry->timer_id) timer_remove(entry->timer_id); if(entry->hello_timer_id) timer_remove(entry->hello_timer_id); if(entry->ack_timer_id) timer_remove(entry->ack_timer_id); free(entry); return; } } }
/* free manager */ void as_sessman_free (ASSessMan *man) { if (!man) return; timer_remove (man->maintenance_timer); /* disconnect everything */ as_sessman_connect (man, 0); free (man); }
NS_STATIC void NS_CLASS timer_add(struct timer *t) { struct timer *curr, *prev; /* Sanity checks: */ if (!t) { perror("NULL timer!!!\n"); exit(-1); } if (!t->handler) { perror("NULL handler!!!\n"); exit(-1); } /* Make sure we remove unexpired timers before adding a new timeout... */ if (t->used) timer_remove(t); t->used = 1; #ifdef DEBUG_TIMER_QUEUE printf("New timer added!\n"); #endif /* Base case when queue is empty: */ if (!TQ) { TQ = t; t->next = NULL; /* Since we insert first in the queue we must reschedule the first timeout */ goto end; } for (prev = NULL, curr = TQ; curr; prev = curr, curr = curr->next) if (timeval_diff(&t->timeout, &curr->timeout) < 0) break; if (curr == TQ) { /* We insert first in queue */ t->next = TQ; TQ = t; } else { t->next = curr; prev->next = t; } end: #ifdef DEBUG_TIMER_QUEUE printTQ(); #endif return; }
void opn_download_free(OpnDownload *dl) { if (!dl) return; OPENNAP->downloads = list_remove(OPENNAP->downloads, dl); tcp_close(dl->con); timer_remove(dl->retry_timer); opn_url_free(dl->url); free(dl); }
static int timer_handler(etimer_t *timer) { unsigned long long missed; if (read(timer->fd, &missed, sizeof (missed)) == -1) error("read timer"); if (timer->cb(timer->data)) { return !timer_remove(timer); } return 0; }
static NwRcT s11_sgw_stop_timer_wrapper( NwGtpv2cTimerMgrHandleT tmrMgrHandle, NwGtpv2cTimerHandleT tmrHandle) { int ret; long timer_id; timer_id = (long)tmrHandle; ret = timer_remove(timer_id); //TODO return ret == 0 ? NW_OK : NW_FAILURE; }
void VOTRAXSC01_sh_stop(void) { if ( votraxsc01_locals.timer ) timer_remove(votraxsc01_locals.timer); votraxsc01_locals.timer = 0; if ( votraxsc01_locals.lpBuffer ) { free(votraxsc01_locals.lpBuffer); votraxsc01_locals.lpBuffer = NULL; } #ifdef REAL_DEVICE DlPortWritePortUshort(_ctrlOutAdr, 0x01); #endif }
static void opennap_destroy(Protocol *p) { if (!OPENNAP) return; timer_remove(OPENNAP->connect_timer); config_free(OPENNAP->cfg); tcp_close(OPENNAP->con); opn_searches_free(OPENNAP->searches); opn_sessions_free(OPENNAP->sessions); opn_nodelist_free(OPENNAP->nodelist); free(OPENNAP); }
/* This is called when we stop receiveing hello messages from a node. For now this is basically the same as a route timeout. */ void hello_timeout(void *arg) { rt_table_t *rt_entry; rt_entry = (rt_table_t *)arg; #ifdef DEBUG log(LOG_DEBUG, 0, "hello_timeout: %s", ip_to_str(rt_entry->dest_addr)); #endif rt_entry->hello_timer_id = 0; if(rt_entry != NULL) { timer_remove(rt_entry->timer_id); route_expire_timeout(rt_entry); } }
static void TimerHandler_3812(int c,double period) { if( period == 0 ) { /* Reset FM Timer */ if( Timer_3812[c] ) { timer_remove(Timer_3812[c]); Timer_3812[c] = 0; } } else { /* Start FM Timer */ Timer_3812[c] = timer_set(period, c, timer_callback_3812 ); } }