void nemo_job_queue_add_new_job (NemoJobQueue *self, GIOSchedulerJobFunc job_func, gpointer user_data, GCancellable *cancellable, NemoProgressInfo *info, gboolean start_immediately) { if (g_list_find_custom (self->priv->queued_jobs, user_data, (GCompareFunc) compare_job_data_func) != NULL) { g_warning ("Adding the same file job object to the job queue"); return; } Job *new_job = g_slice_new0 (Job); new_job->job_func = job_func; new_job->user_data = user_data; new_job->cancellable = cancellable; new_job->info = info; self->priv->queued_jobs = g_list_append (self->priv->queued_jobs, new_job); nemo_progress_info_queue (info); g_signal_connect_swapped (info, "finished", G_CALLBACK (job_finished_cb), self); if (self->priv->skip_queue || start_immediately) start_job (self, new_job); else nemo_job_queue_start_next_job (self); g_signal_emit (self, signals[NEW_JOB], 0, NULL); }
void pipe_setup( char *cluster, char *proc, char * /*capability*/ ) { static char host[1024]; UsePipes = TRUE; dprintf( D_ALWAYS, "Job = %s.%s\n", cluster, proc ); if( Spool ) { free( Spool ); } Spool = param( "SPOOL" ); if( Spool == NULL ) { EXCEPT( "Spool directory not specified in config file" ); } snprintf( host, 1024, "%s", get_local_hostname().Value() ); ExecutingHost = host; open_named_pipe( "/tmp/syscall_req", O_RDONLY, REQ_SOCK ); dprintf( D_ALWAYS, "Shadow: REQ_SOCK connected, fd = %d\n", REQ_SOCK ); open_named_pipe( "/tmp/syscall_rpl", O_WRONLY, RPL_SOCK ); dprintf( D_ALWAYS, "Shadow: RPL_SOCK connected, fd = %d\n", RPL_SOCK ); open_named_pipe( "/tmp/log", O_RDONLY, CLIENT_LOG ); dprintf( D_ALWAYS, "Shadow: CLIENT_LOG connected, fd = %d\n", CLIENT_LOG ); sock_RSC1 = RSC_ShadowInit( RSC_SOCK, CLIENT_LOG ); start_job( cluster, proc ); }
int main(int argc, char** argv) { const char* command = "list"; bool verbose = false; int c; while ((c = getopt_long(argc, argv, "+hv", kLongOptions, NULL)) != -1) { switch (c) { case 0: break; case 'h': usage(0); break; case 'v': verbose = true; break; default: usage(1); break; } } if (argc - optind >= 1) command = argv[optind]; if (strcmp(command, "list") == 0) { list_jobs(verbose); } else if (strcmp(command, "list-targets") == 0) { list_targets(verbose); } else if (strcmp(command, "log") == 0) { get_log(argc - optind, &argv[optind]); } else if (argc == optind + 1) { // For convenience (the "info" command can be omitted) get_info(command); } else { // All commands that need a name following const char* name = argv[argc - 1]; if (strcmp(command, "info") == 0) { get_info(name); } else if (strcmp(command, "start") == 0) { start_job(name); } else if (strcmp(command, "stop") == 0) { stop_job(name); } else if (strcmp(command, "restart") == 0) { restart_job(name); } else if (strcmp(command, "enable") == 0) { enable_job(name, true); } else if (strcmp(command, "disable") == 0) { enable_job(name, false); } else { fprintf(stderr, "%s: Unknown command \"%s\".\n", kProgramName, command); } } return 0; }
int get_opt(int argc, char *argv[]) { if (argc < 2) { print_usage(argv[0]); exit(-1); } if (strcmp(argv[1], "-oz") == 0) { if (argc < 4) { print_usage(argv[0]); exit(-1); } printf("[only compress files]\n"); start_job(argc, argv, 0); } else if (strcmp(argv[1], "-ou") == 0) { if (argc < 4) { print_usage(argv[0]); exit(-1); } printf("[only uncompress files]\n"); start_job(argc, argv, 1); } else { if (argc < 4) { print_usage(argv[0]); exit(-1); } printf("[compress & decompress files]\n"); start_job(argc, argv, 2); } return 0; }
void compare_file_lists(File_t * first, File_t * second) { bool store_state = false; int modifications = 0; // if a child cannot connect get out of here! modifications += act_on_file_add(first, second); modifications += act_on_file_del(first, second); modifications += act_on_file_mod(first, second); if (modifications) { File_t files[modifications]; memset(files, 0, sizeof(File_t) * modifications); int i = 0; File_t *cursor = first->next; while (cursor) { if (cursor->changed) { memcpy(&files[i], cursor, sizeof(File_t)); i++; } cursor = cursor->next; } cursor = second->next; while (cursor) { if (cursor->changed) { memcpy(&files[i], cursor, sizeof(File_t)); i++; } cursor = cursor->next; //oops! } store_state = true; int total_files = modifications; for (int i = 0; i < total_files; i++) { start_job(&files[i]); } wait_for_all_jobs(); printf("done!\n\n"); } if ((!*connection_broken) && (new_repository || store_state)) { save_file_list_state(second); } }
void nemo_job_queue_start_job_by_info (NemoJobQueue *self, NemoProgressInfo *info) { GList *target = g_list_find_custom (self->priv->queued_jobs, info, (GCompareFunc) compare_info_func); if (target) start_job (self, target->data); }
File_t *first_run(char *path) { char state_file_path[PATH_MAX] = { 0 }; snprintf(state_file_path, PATH_MAX, "%s%c%s", drop_config_directory, SLASH, DROP_STATE_FILE); struct stat fstats; File_t *list = NULL; if (stat(state_file_path, &fstats) < 0) { if (debugging) { printf("this is the first run\n"); } list = files_in_directory(path); if (new_repository) { File_t *cursor = list->next; while (cursor) { cursor->changed = FILE_ADD; printf("init file %s\n", cursor->path); start_job(cursor); cursor = cursor->next; } wait_for_all_jobs(); printf("done!\n"); } } else { list = files_from_state_file(state_file_path); } return list; }
void regular_setup( char *host, char *cluster, char *proc ) { dprintf( D_ALWAYS, "Hostname = \"%s\", Job = %s.%s\n", host, cluster, proc ); if( Spool ) { free( Spool ); } Spool = param( "SPOOL" ); if( Spool == NULL ) { EXCEPT( "Spool directory not specified in config file" ); } if (host[0] != '<') { EXCEPT( "Want sinful string !!" ); } ExecutingHost = host; start_job( cluster, proc ); send_job( Proc, host ); }
void nemo_job_queue_start_next_job (NemoJobQueue *self) { if (g_list_length (self->priv->running_jobs) == 0 && g_list_length (self->priv->queued_jobs) > 0) start_job (self, self->priv->queued_jobs->data); }
/* This is called at main or AST level. It is at AST level for DONTWAITFORCHILD and at main level otherwise. In any case it is called when a child process terminated. At AST level it won't get interrupted by anything except a inner mode level AST. */ int vmsHandleChildTerm(struct child *child) { int status; register struct child *lastc, *c; int child_failed; vms_jobsefnmask &= ~(1 << (child->efn - 32)); lib$free_ef (&child->efn); if (child->comname) { if (!ISDB (DB_JOBS) && !ctrlYPressed) unlink (child->comname); free (child->comname); } (void) sigblock (fatal_signal_mask); child_failed = !(child->cstatus & 1 || ((child->cstatus & 7) == 0)); /* Search for a child matching the deceased one. */ lastc = 0; #if defined(RECURSIVEJOBS) /* I've had problems with recursive stuff and process handling */ for (c = children; c != 0 && c != child; lastc = c, c = c->next) ; #else c = child; #endif if (child_failed && !c->noerror && !ignore_errors_flag) { /* The commands failed. Write an error message, delete non-precious targets, and abort. */ child_error (c, c->cstatus, 0, 0, 0); c->file->update_status = us_failed; delete_child_targets (c); } else { if (child_failed) { /* The commands failed, but we don't care. */ child_error (c, c->cstatus, 0, 0, 1); child_failed = 0; } #if defined(RECURSIVEJOBS) /* I've had problems with recursive stuff and process handling */ /* If there are more commands to run, try to start them. */ start_job (c); switch (c->file->command_state) { case cs_running: /* Successfully started. */ break; case cs_finished: if (c->file->update_status != us_success) /* We failed to start the commands. */ delete_child_targets (c); break; default: OS (error, NILF, _("internal error: '%s' command_state"), c->file->name); abort (); break; } #endif /* RECURSIVEJOBS */ } /* Set the state flag to say the commands have finished. */ c->file->command_state = cs_finished; notice_finished_file (c->file); #if defined(RECURSIVEJOBS) /* I've had problems with recursive stuff and process handling */ /* Remove the child from the chain and free it. */ if (lastc == 0) children = c->next; else lastc->next = c->next; free_child (c); #endif /* RECURSIVEJOBS */ /* There is now another slot open. */ if (job_slots_used > 0) --job_slots_used; /* If the job failed, and the -k flag was not given, die. */ if (child_failed && !keep_going_flag) die (EXIT_FAILURE); (void) sigsetmask (sigblock (0) & ~(fatal_signal_mask)); return 1; }
/*****************************************************************************\ * Parse, process and respond to a request \*****************************************************************************/ static void _proc_msg(slurm_fd_t new_fd, char *msg) { DEF_TIMERS; char *req, *cmd_ptr, *msg_type = NULL; char response[128]; if (new_fd < 0) return; START_TIMER; if (!msg) { err_code = -300; err_msg = "NULL request message"; error("wiki: NULL request message"); goto resp_msg; } if (_parse_msg(msg, &req) != 0) goto resp_msg; cmd_ptr = strstr(req, "CMD="); if (cmd_ptr == NULL) { err_code = -300; err_msg = "request lacks CMD"; error("wiki: request lacks CMD"); goto resp_msg; } cmd_ptr +=4; err_code = 0; if (strncmp(cmd_ptr, "GETJOBS", 7) == 0) { msg_type = "wiki:GETJOBS"; if (!get_jobs(cmd_ptr, &err_code, &err_msg)) goto free_resp_msg; } else if (strncmp(cmd_ptr, "GETNODES", 8) == 0) { msg_type = "wiki:GETNODES"; if (!get_nodes(cmd_ptr, &err_code, &err_msg)) goto free_resp_msg; } else if (strncmp(cmd_ptr, "STARTJOB", 8) == 0) { msg_type = "wiki:STARTJOB"; start_job(cmd_ptr, &err_code, &err_msg); } else if (strncmp(cmd_ptr, "CANCELJOB", 9) == 0) { msg_type = "wiki:CANCELJOB"; cancel_job(cmd_ptr, &err_code, &err_msg); } else if (strncmp(cmd_ptr, "SUSPENDJOB", 10) == 0) { msg_type = "wiki:SUSPENDJOB"; suspend_job(cmd_ptr, &err_code, &err_msg); } else if (strncmp(cmd_ptr, "RESUMEJOB", 9) == 0) { msg_type = "wiki:RESUMEJOB"; resume_job(cmd_ptr, &err_code, &err_msg); } else if (strncmp(cmd_ptr, "MODIFYJOB", 9) == 0) { msg_type = "wiki:MODIFYJOB"; job_modify_wiki(cmd_ptr, &err_code, &err_msg); } else { err_code = -300; err_msg = "unsupported request type"; error("wiki: unrecognized request type: %s", req); } END_TIMER2(msg_type); resp_msg: snprintf(response, sizeof(response), "SC=%d RESPONSE=%s", err_code, err_msg); _send_reply(new_fd, response); return; free_resp_msg: /* Message is pre-formatted by get_jobs and get_nodes * ONLY if no error. Send message and xfree the buffer. */ _send_reply(new_fd, err_msg); xfree(err_msg); return; }
/*****************************************************************************\ * Parse, process and respond to a request \*****************************************************************************/ static void _proc_msg(slurm_fd_t new_fd, char *msg) { DEF_TIMERS; char *req, *cmd_ptr, *msg_type = NULL; char response[128]; if (new_fd < 0) return; START_TIMER; if (!msg) { err_code = -300; err_msg = "NULL request message"; error("wiki: NULL request message"); goto resp_msg; } if (_parse_msg(msg, &req) != 0) goto resp_msg; cmd_ptr = strstr(req, "CMD="); if (cmd_ptr == NULL) { err_code = -300; err_msg = "request lacks CMD"; error("wiki: request lacks CMD"); goto resp_msg; } cmd_ptr +=4; err_code = 0; if (strncmp(cmd_ptr, "GETJOBS", 7) == 0) { msg_type = "wiki:GETJOBS"; if (!get_jobs(cmd_ptr, &err_code, &err_msg)) goto free_resp_msg; } else if (strncmp(cmd_ptr, "GETNODES", 8) == 0) { msg_type = "wiki:GETNODES"; if (!get_nodes(cmd_ptr, &err_code, &err_msg)) goto free_resp_msg; } else if (strncmp(cmd_ptr, "STARTJOB", 8) == 0) { msg_type = "wiki:STARTJOB"; start_job(cmd_ptr, &err_code, &err_msg); } else if (strncmp(cmd_ptr, "CANCELJOB", 9) == 0) { msg_type = "wiki:CANCELJOB"; cancel_job(cmd_ptr, &err_code, &err_msg); } else if (strncmp(cmd_ptr, "REQUEUEJOB", 10) == 0) { msg_type = "wiki:REQUEUEJOB"; job_requeue_wiki(cmd_ptr, &err_code, &err_msg); } else if (strncmp(cmd_ptr, "SUSPENDJOB", 10) == 0) { msg_type = "wiki:SUSPENDJOB"; suspend_job(cmd_ptr, &err_code, &err_msg); } else if (strncmp(cmd_ptr, "RESUMEJOB", 9) == 0) { msg_type = "wiki:RESUMEJOB"; resume_job(cmd_ptr, &err_code, &err_msg); } else if (strncmp(cmd_ptr, "JOBADDTASK", 10) == 0) { msg_type = "wiki:JOBADDTASK"; job_add_task(cmd_ptr, &err_code, &err_msg); } else if (strncmp(cmd_ptr, "JOBRELEASETASK", 14) == 0) { msg_type = "wiki:JOBRELEASETASK"; job_release_task(cmd_ptr, &err_code, &err_msg); } else if (strncmp(cmd_ptr, "JOBWILLRUN", 10) == 0) { msg_type = "wiki:JOBWILLRUN"; if (strstr(cmd_ptr, "NODES=")) { /* Updated format input and output */ if (!job_will_run2(cmd_ptr, &err_code, &err_msg)) goto free_resp_msg; } else { if (!job_will_run(cmd_ptr, &err_code, &err_msg)) goto free_resp_msg; } } else if (strncmp(cmd_ptr, "MODIFYJOB", 9) == 0) { msg_type = "wiki:MODIFYJOB"; job_modify_wiki(cmd_ptr, &err_code, &err_msg); } else if (strncmp(cmd_ptr, "NOTIFYJOB", 9) == 0) { msg_type = "wiki:NOTIFYJOB"; job_notify_wiki(cmd_ptr, &err_code, &err_msg); } else if (strncmp(cmd_ptr, "SIGNALJOB", 9) == 0) { msg_type = "wiki:SIGNALJOB"; job_signal_wiki(cmd_ptr, &err_code, &err_msg); } else if (strncmp(cmd_ptr, "INITIALIZE", 10) == 0) { msg_type = "wiki:INITIALIZE"; initialize_wiki(cmd_ptr, &err_code, &err_msg); } else { err_code = -300; err_msg = "unsupported request type"; error("wiki: unrecognized request type: %s", req); } END_TIMER2(msg_type); resp_msg: snprintf(response, sizeof(response), "SC=%d RESPONSE=%s", err_code, err_msg); _send_reply(new_fd, response); return; free_resp_msg: /* Message is pre-formatted by get_jobs and get_nodes * ONLY if no error. Send message and xfree the buffer. */ _send_reply(new_fd, err_msg); xfree(err_msg); return; }
static void restart_job(const char* name) { stop_job(name); start_job(name); }
EXPORT void audgui_export_playlist (void) { audgui_show_unique_window (AUDGUI_PLAYLIST_EXPORT_WINDOW, start_job (TRUE)); }
EXPORT void audgui_import_playlist (void) { audgui_show_unique_window (AUDGUI_PLAYLIST_IMPORT_WINDOW, start_job (FALSE)); }
static gsize request_gstreamill_admin (HTTPMgmt *httpmgmt, RequestData *request_data, gchar **buf) { gchar *path, *http_header, *p; gsize buf_size; GError *err = NULL; path = NULL; if (g_strcmp0 (request_data->uri, "/admin/") == 0) { path = g_strdup_printf ("%s/gstreamill/admin/index.html", DATADIR); } else if (g_str_has_prefix (request_data->uri, "/admin/start")) { p = start_job (httpmgmt, request_data); *buf = g_strdup_printf (http_200, PACKAGE_NAME, PACKAGE_VERSION, "application/json", strlen (p), NO_CACHE, p); g_free (p); } else if (g_str_has_prefix (request_data->uri, "/admin/stop")) { p = stop_job (httpmgmt, request_data); *buf = g_strdup_printf (http_200, PACKAGE_NAME, PACKAGE_VERSION, "application/json", strlen (p), NO_CACHE, p); g_free (p); } else if (g_strcmp0 (request_data->uri, "/admin/networkinterfaces") == 0) { p = network_interfaces (); *buf = g_strdup_printf (http_200, PACKAGE_NAME, PACKAGE_VERSION, "application/json", strlen (p), NO_CACHE, p); g_free (p); } else if (g_strcmp0 (request_data->uri, "/admin/setnetworkinterfaces") == 0) { p = set_network_interfaces (request_data); *buf = g_strdup_printf (http_200, PACKAGE_NAME, PACKAGE_VERSION, "application/json", strlen (p), NO_CACHE, p); g_free (p); } else if (g_strcmp0 (request_data->uri, "/admin/networkdevices") == 0) { p = network_devices (); *buf = g_strdup_printf (http_200, PACKAGE_NAME, PACKAGE_VERSION, "application/json", strlen (p), NO_CACHE, p); g_free (p); } else if (g_strcmp0 (request_data->uri, "/admin/audiodevices") == 0) { p = list_files ("/dev/snd/pcmC*c", NULL); *buf = g_strdup_printf (http_200, PACKAGE_NAME, PACKAGE_VERSION, "application/json", strlen (p), NO_CACHE, p); g_free (p); } else if (g_strcmp0 (request_data->uri, "/admin/videodevices") == 0) { p = list_files ("/dev/video*", NULL); *buf = g_strdup_printf (http_200, PACKAGE_NAME, PACKAGE_VERSION, "application/json", strlen (p), NO_CACHE, p); g_free (p); } else if (g_strcmp0 (request_data->uri, "/admin/getconf") == 0) { p = get_conf (); *buf = g_strdup_printf (http_200, PACKAGE_NAME, PACKAGE_VERSION, "application/json", strlen (p), NO_CACHE, p); g_free (p); } else if ((request_data->method == HTTP_POST) && (g_strcmp0 (request_data->uri, "/admin/putconf") == 0)) { p = put_conf (request_data); *buf = g_strdup_printf (http_200, PACKAGE_NAME, PACKAGE_VERSION, "application/json", strlen (p), NO_CACHE, p); g_free (p); } else if (g_strcmp0 (request_data->uri, "/admin/listlivejob") == 0) { p = list_files ("/etc/gstreamill.d/*.job", "/etc/gstreamill.d/%[^.].job"); *buf = g_strdup_printf (http_200, PACKAGE_NAME, PACKAGE_VERSION, "application/json", strlen (p), NO_CACHE, p); g_free (p); } else if (g_strcmp0 (request_data->uri, "/admin/listrunningjob") == 0) { p = gstreamill_list_running_job (httpmgmt->gstreamill); *buf = g_strdup_printf (http_200, PACKAGE_NAME, PACKAGE_VERSION, "application/json", strlen (p), NO_CACHE, p); g_free (p); } else if (g_str_has_prefix (request_data->uri, "/admin/getjob/")) { p = get_job (request_data->uri); if (p != NULL) { *buf = g_strdup_printf (http_200, PACKAGE_NAME, PACKAGE_VERSION, "application/json", strlen (p), NO_CACHE, p); g_free (p); } else { *buf = g_strdup_printf (http_404, PACKAGE_NAME, PACKAGE_VERSION); } } else if (g_str_has_prefix (request_data->uri, "/admin/rmjob/")) { p = rm_job (request_data->uri); *buf = g_strdup_printf (http_200, PACKAGE_NAME, PACKAGE_VERSION, "application/json", strlen (p), NO_CACHE, p); g_free (p); } else if ((request_data->method == HTTP_POST) && (g_str_has_prefix (request_data->uri, "/admin/putjob/"))) { p = put_job (request_data); *buf = g_strdup_printf (http_200, PACKAGE_NAME, PACKAGE_VERSION, "application/json", strlen (p), NO_CACHE, p); g_free (p); } else if (g_str_has_prefix (request_data->uri, "/admin/jobmanage.html")) { if (g_str_has_prefix (request_data->parameters, "name=")) { path = g_strdup_printf ("%s/gstreamill/admin/jobmanage.html", DATADIR); } else { *buf = g_strdup_printf (http_400, PACKAGE_NAME, PACKAGE_VERSION); } } else { /* static content, prepare file path */ path = g_strdup_printf ("%s/gstreamill%s", DATADIR, request_data->uri); } if (path == NULL) { /* not static content */ buf_size = strlen (*buf); } else if (!g_file_get_contents (path, buf, &buf_size, &err)) { GST_ERROR ("read file %s failure: %s", p, err->message); *buf = g_strdup_printf (http_404, PACKAGE_NAME, PACKAGE_VERSION); buf_size = strlen (*buf); g_error_free (err); } else { /* jobmanage.html? process name parameter */ if (g_str_has_suffix (path, "jobmanage.html")) { gchar name[32], *temp_buf; sscanf (request_data->parameters, "name=%s", name); temp_buf = g_strdup_printf (*buf, name); g_free (*buf); *buf = temp_buf; } /* html file? add top and bottom */ if (g_str_has_suffix (path, ".html")) { gchar *body; body = *buf; *buf = add_header_footer (body); g_free (body); buf_size = strlen (*buf); } http_header = gen_http_header (path, buf_size); p = g_malloc (buf_size + strlen (http_header)); memcpy (p, http_header, strlen (http_header)); memcpy (p + strlen (http_header), *buf, buf_size); g_free (*buf); *buf = p; buf_size += strlen (http_header); g_free (http_header); } if (path != NULL) { g_free (path); } return buf_size; }