void CallManager::handle_DropResponse( const simple_voip::CallbackObject * oobj ) { auto * obj = dynamic_cast< const simple_voip::DropResponse *>( oobj ); auto it = map_drop_req_id_to_call_id_.find( obj->req_id ); if( it == map_drop_req_id_to_call_id_.end() ) return; auto call_id = it->second; map_drop_req_id_to_call_id_.erase( it ); auto it_2 = active_call_ids_.find( call_id ); if( it_2 == active_call_ids_.end() ) { dummy_log_warn( log_id_, "unknown call id %u", call_id ); return; } active_call_ids_.erase( it_2 ); process_jobs(); }
void CallManager::handle_ErrorResponse( const simple_voip::CallbackObject * oobj ) { auto * obj = dynamic_cast< const simple_voip::ErrorResponse *>( oobj ); auto it = active_request_ids_.find( obj->req_id ); if( it == active_request_ids_.end() ) { erase_failed_drop_request( obj->req_id ); return; } active_request_ids_.erase( it ); process_jobs(); }
void CallManager::handle_failed_call( uint32_t call_id ) { dummy_log_debug( log_id_, "failed call id %u", call_id ); auto it = active_call_ids_.find( call_id ); if( it == active_call_ids_.end() ) { dummy_log_warn( log_id_, "unknown call id %u", call_id ); return; } active_call_ids_.erase( it ); process_jobs(); }
/* * Processing in common between topq and bottomq commands. */ void tqbq_common(int argc, char *argv[], int origcmd) { struct printer myprinter, *pp; struct touchjqe_info touch_info; int i, movecnt, setres; pp = setup_myprinter(*argv, &myprinter, SUMP_CHDIR_SD); if (pp == NULL) return; --argc; /* Second argv was the printer name */ ++argv; nitems = getq(pp, &queue); if (nitems == 0) { printf("\tthere are no jobs in the queue\n"); free_printer(pp); return; } /* * The only real difference between topq and bottomq is the * initial value used for newtime. */ switch (origcmd) { case IS_BOTQ: /* * When moving jobs to the bottom of the queue, pick a * starting value which is one second after the last job * in the queue. */ touch_info.newtime = queue[nitems - 1]->job_time + 1; break; case IS_TOPQ: /* * When moving jobs to the top of the queue, the greatest * number of jobs which could be moved is all the jobs * that are in the queue. Pick a starting value which * leaves plenty of room for all existing jobs. */ touch_info.newtime = queue[0]->job_time - nitems - 5; break; default: printf("\ninternal error in topq/bottomq processing.\n"); return; } movecnt = process_jobs(argc, argv, touch_jqe, &touch_info); /* * If any jobs were moved, then chmod the lock file to notify any * active process for this queue that the queue has changed, so * it will rescan the queue to find out the new job order. */ if (movecnt == 0) printf("\tqueue order unchanged\n"); else { setres = set_qstate(SQS_QCHANGED, pp->lock_file); if (setres < 0) printf("\t* queue order changed for %s, but the\n" "\t* attempt to set_qstate() failed [%d]!\n", pp->printer, setres); } for (i = 0; i < nitems; i++) free(queue[i]); free(queue); free_printer(pp); }
int main (int argc, char *argv[]) { char *subopts, *value; int opt, sjf = 0, fcfs = 0, srtf = 0, rr = 0, unix_sched = 0, verbose = 0, number_of_jobs = 0, no_scheduler = 1; char *filename = NULL; if(argc == 1) { print_usage(argc, argv); return 1; } while((opt = getopt(argc, argv, "hvn:i:s:")) != -1) switch(opt) { case 'h': print_usage(argc, argv); break; case 'v': verbose = 1; break; case 'n': number_of_jobs = strtol(optarg, NULL, 10); break; case 'i': filename = optarg; break; case 's': subopts = optarg; while(*subopts != '\0') switch(getsubopt(&subopts, scheduler_opts, &value)) { case SJF: sjf = 1; break; case FCFS: fcfs = 1; break; case SRTF: srtf = 1; break; case RR: rr = 1; break; case UNIX: unix_sched = 1; break; default: printf("unknown scheduler passed in list to -s\n"); break; } no_scheduler = 0; break; default: print_usage(argc, argv); abort(); break; } if(number_of_jobs > 0 && filename) { fprintf(stderr, "cannot specify both -n and -i parameters.\n"); print_usage(argc, argv); return 1; } if(number_of_jobs == 0 && filename == NULL) { fprintf(stderr, "must specify either -n or -i parameter.\n"); print_usage(argc, argv); return 1; } if(no_scheduler) { fprintf(stderr, "must specify a scheduler with -s parameter.\n"); print_usage(argc, argv); return 1; } if(sjf) process_jobs(sjf_comparison, filename, number_of_jobs, verbose); if(fcfs) process_jobs(fcfs_comparison, filename, number_of_jobs, verbose); if(srtf) process_jobs(srtf_comparison, filename, number_of_jobs, verbose); if(rr) process_jobs(rr_comparison, filename, number_of_jobs, verbose); if(unix_sched) process_jobs(unix_comparison, filename, number_of_jobs, verbose); return 0; }