int force(void) { if (shutdown_pending) { pr("Shutdown is pending\n"); return RET_FAIL; } if (updates_disabled()) { pr("Updates are disabled\n"); return RET_FAIL; } if (update_trigger() < 0) return RET_FAIL; return RET_OK; }
void *thread_trigger(void *arg) { int trigger_no = *(int *) arg; while (!shutdown) { if (wait_for_sem(&trigger_update_sems[trigger_no]) == -1) { continue; } update_trigger(trigger_no); sem_post(&trigger_updated_sems[trigger_no]); notify_actions(); } exit_thread("trigger", trigger_no, triggers[trigger_no].name); }
/* * Trigger for sending the DATABASE event * * Needs to be called, if an update to the database (library tables) occurred. The DATABASE event * is emitted with the delay 'library_update_wait'. It is safe to call this function from any thread. */ void library_update_trigger(short update_events) { short *events; int ret; pthread_t current_thread = pthread_self(); if (pthread_equal(current_thread, tid_library)) { // We are already running in the library thread, it is safe to directly call update_trigger update_trigger(&update_events, &ret); } else { events = malloc(sizeof(short)); *events = update_events; commands_exec_async(cmdbase, update_trigger, events); } }
void* eread(void* pv) { int k,i,fd; fd=*((int*)pv); char buf[64]; char* ps[2]={"off","on"}; while(1) { k=read(fd,buf,64); printf("k=%d\n",k); if(k<0) { perror("read"); exit(2); } if(k==0) { printf("no data from aoa\n"); } if(buf[0]==0x41) update_leds(buf[1]-1,buf[2]); if(buf[0]==0x42) update_trigger(buf[1]-1,buf[2]); //if(buf[0]==0x43) update_seek(buf[1]); } }
int zdon(void) { int whichcnum; struct natstr *natp; char *p; int checking; int wantupd; int totpop; int totwant; int dowant; char buf[1024]; if (update_demand != UPD_DEMAND_SCHED && update_demand != UPD_DEMAND_ASYNC) { pr("Demand updates are not enabled.\n"); return RET_FAIL; } p = getstarg(player->argp[1], "Want update? [Yes|No|Check] ", buf); if (!p) return RET_SYN; if (*p == 'y' || *p == 'Y') { checking = 0; wantupd = 1; } else if (*p == 'n' || *p == 'N') { checking = 0; wantupd = 0; } else { checking = 1; wantupd = 0; } if (player->god) { whichcnum = natarg(player->argp[2], "for which country? "); if (whichcnum < 0) return RET_SYN; } else whichcnum = player->cnum; if (!(natp = getnatp(whichcnum))) { pr("Unable to find country. %d\n", whichcnum); pr("Notify the Deity.\n"); return RET_FAIL; } if (!checking) { if (wantupd) { if (influx(natp)) { pr("Unable to request an update as the country is in flux\n"); return RET_FAIL; } pr("You (%d) now want an update.\n", whichcnum); } else { pr("You (%d) now DON'T want an update.\n", whichcnum); } natp->nat_update = wantupd; putnat(natp); } dowant = demand_update_want(&totwant, &totpop, whichcnum); if (checking) { if (dowant) { pr("You want an update.\n"); } else pr("You DON'T want an update, yet.\n"); } pr("%d of a total of %d lunatics want an update.\n", totwant, totpop); if (!checking && wantupd && demandupdatecheck()) { pr("Here goes...\n"); update_trigger(); } return RET_OK; }