/** @par Detailed Design: */ int Trick::MonteCarlo::prepare_run(MonteRun *curr_run) { current_run = curr_run->id; /** <ul><li> If this run has never been dispatched: */ if (curr_run->num_tries == 0) { /** <ul><li> Run the pre run jobs. */ run_queue(&master_pre_queue, "in master_pre queue") ; /** <li> Add the variables to the curr_run and check for end of file and value generation failures. */ for (std::vector<std::string>::size_type i = 0; i < variables.size(); ++i) { curr_run->variables.push_back(variables[i]->get_next_value()); if (curr_run->variables.back() == "EOF") { if (verbosity >= ALL) { message_publish(MSG_WARNING, "Monte [Master] File variable '%s' reached end-of-file. Reducing number of runs to %d.\n", variables[i]->name.c_str(), curr_run->id) ; } set_num_runs(curr_run->id); return -1; } } /** <li> Create the data file </ul>*/ fprintf(run_data_file, "%05u\t", curr_run->id); for (std::vector<std::string>::size_type i = 0; i < variables.size(); ++i) { if (i>0) { fprintf(run_data_file, "\t"); } fprintf(run_data_file, "%s", variables[i]->value.c_str()); } fprintf(run_data_file, "\n"); } /** <li> Dequeue the run. */ dequeue_run(curr_run); return 0; }
static void resolved_proxy_uri (SoupProxyURIResolver *proxy_resolver, guint status, SoupURI *proxy_uri, gpointer user_data) { SoupMessageQueueItem *item = user_data; SoupSession *session = item->session; if (item_failed (item, status)) return; if (proxy_uri) { SoupAddress *proxy_addr; item->state = SOUP_MESSAGE_RESOLVING_PROXY_ADDRESS; item->proxy_uri = soup_uri_copy (proxy_uri); proxy_addr = soup_address_new (proxy_uri->host, proxy_uri->port); soup_address_resolve_async (proxy_addr, soup_session_get_async_context (session), item->cancellable, resolved_proxy_addr, item); g_object_unref (proxy_addr); return; } item->state = SOUP_MESSAGE_AWAITING_CONNECTION; soup_message_queue_item_unref (item); /* If we got here we know session still exists */ run_queue ((SoupSessionAsync *)session); }
/** @par Detailed Design: */ int Trick::MonteCarlo::shutdown() { /** <ul><li> If this is a slave, run the shutdown jobs. */ if (enabled && is_slave()) { connection_device.port = master_port; if (tc_connect(&connection_device) == TC_SUCCESS) { int exit_status = MonteRun::COMPLETE; if (verbosity >= ALL) { message_publish(MSG_INFO, "Monte [%s:%d] Sending run exit status to master: %d\n", machine_name.c_str(), slave_id, exit_status) ; } int id = htonl(slave_id); tc_write(&connection_device, (char*)&id, (int)sizeof(id)); exit_status = htonl(exit_status); tc_write(&connection_device, (char*)&exit_status, (int)sizeof(exit_status)); run_queue(&slave_post_queue, "in slave_post queue"); tc_disconnect(&connection_device); } else { if (verbosity >= ERROR) message_publish( MSG_ERROR, "Monte [%s:%d] Failed to connect to master.\n", machine_name.c_str(), slave_id); } } return 0; }
int main(int argc, char *argv[]){ char buf[BUF_SIZE]; coord place, holder; init(argc, argv); holder.x = holder.y = place.x = place.y = SIZE/2; app_1(place); show_all(holder); run(place); show_all(holder); do{ place = queue[qbeg].place; run_queue(); show_all(holder); run(place); show_all(holder); } while(queue_population() > 0); SHOULD(count(INTEGER) == 1); SHOULD(count(LOCAL) == 0); SHOULD(count(LAMBDA) == 0); SHOULD(count(SYMBOL) == 0); place.x = place.y = SIZE/2; onc_to_string(place, buf, 0); debug(1, "(%d,%d):%s\n", place.x, place.y, buf); debug(1, "integer:%d local:%d lambda:%d symbol:%d\n", count(INTEGER), count(LOCAL), count(LAMBDA), count(SYMBOL)); /* return indicates success or failure */ return fail_p; }
static void request_restarted (SoupMessage *req, gpointer user_data) { SoupMessageQueueItem *item = user_data; run_queue ((SoupSessionAsync *)item->session); }
static gboolean idle_run_queue (gpointer sa) { SoupSessionAsyncPrivate *priv = SOUP_SESSION_ASYNC_GET_PRIVATE (sa); priv->idle_run_queue_source = NULL; run_queue (sa); return FALSE; }
/** @par Detailed Design: */ void Trick::MonteCarlo::dryrun() { /** <ul><li> For all runs: run the pre run jobs. */ MonteRun * curr_run; while ((curr_run = get_next_dispatch())) { prepare_run(curr_run); } /** <ul><li> Run the master shutdown jobs */ run_queue(&master_shutdown_queue, "in master_shutdown queue") ; message_publish(MSG_INFO, "Monte [Master] Dry run complete.\n") ; exit(0) ; }
static void resolved_proxy_addr (SoupAddress *addr, guint status, gpointer user_data) { SoupMessageQueueItem *item = user_data; SoupSession *session = item->session; if (item_failed (item, status)) return; item->proxy_addr = g_object_ref (addr); item->state = SOUP_MESSAGE_AWAITING_CONNECTION; soup_message_queue_item_unref (item); /* If we got here we know session still exists */ run_queue ((SoupSessionAsync *)session); }
static void got_connection (SoupConnection *conn, guint status, gpointer user_data) { SoupMessageQueueItem *item = user_data; SoupSession *session = item->session; SoupAddress *tunnel_addr; if (item->state != SOUP_MESSAGE_CONNECTING) { soup_connection_disconnect (conn); do_idle_run_queue (session); soup_message_queue_item_unref (item); g_object_unref (session); return; } if (status != SOUP_STATUS_OK) { soup_session_set_item_status (session, item, status); item->state = SOUP_MESSAGE_FINISHING; soup_connection_disconnect (conn); do_idle_run_queue (session); soup_message_queue_item_unref (item); g_object_unref (session); return; } tunnel_addr = soup_connection_get_tunnel_addr (conn); if (tunnel_addr) { SoupMessageQueueItem *tunnel_item; item->state = SOUP_MESSAGE_TUNNELING; tunnel_item = soup_session_make_connect_message (session, conn); tunnel_item->related = item; soup_session_send_queue_item (session, tunnel_item, tunnel_message_completed); return; } item->state = SOUP_MESSAGE_READY; g_signal_connect (conn, "disconnected", G_CALLBACK (connection_closed), session); run_queue ((SoupSessionAsync *)session); soup_message_queue_item_unref (item); g_object_unref (session); }
void bounce(struct qitem *it, const char *reason) { struct queue bounceq; char line[1000]; size_t pos; int error; /* Don't bounce bounced mails */ if (it->sender[0] == 0) { syslog(LOG_INFO, "can not bounce a bounce message, discarding"); exit(1); } bzero(&bounceq, sizeof(bounceq)); LIST_INIT(&bounceq.queue); bounceq.sender = ""; if (add_recp(&bounceq, it->sender, EXPAND_WILDCARD) != 0) goto fail; if (newspoolf(&bounceq) != 0) goto fail; syslog(LOG_ERR, "delivery failed, bouncing as %s", bounceq.id); setlogident("%s", bounceq.id); error = fprintf(bounceq.mailf, "Received: from MAILER-DAEMON\n" "\tid %s\n" "\tby %s (%s);\n" "\t%s\n" "X-Original-To: <%s>\n" "From: MAILER-DAEMON <>\n" "To: %s\n" "Subject: Mail delivery failed\n" "Message-Id: <%s@%s>\n" "Date: %s\n" "\n" "This is the %s at %s.\n" "\n" "There was an error delivering your mail to <%s>.\n" "\n" "%s\n" "\n" "%s\n" "\n", bounceq.id, hostname(), VERSION, rfc822date(), it->addr, it->sender, bounceq.id, hostname(), rfc822date(), VERSION, hostname(), it->addr, reason, config.features & FULLBOUNCE ? "Original message follows." : "Message headers follow."); if (error < 0) goto fail; if (fseek(it->mailf, 0, SEEK_SET) != 0) goto fail; if (config.features & FULLBOUNCE) { while ((pos = fread(line, 1, sizeof(line), it->mailf)) > 0) { if (fwrite(line, 1, pos, bounceq.mailf) != pos) goto fail; } } else { while (!feof(it->mailf)) { if (fgets(line, sizeof(line), it->mailf) == NULL) break; if (line[0] == '\n') break; if (fwrite(line, strlen(line), 1, bounceq.mailf) != 1) goto fail; } } if (linkspool(&bounceq) != 0) goto fail; /* bounce is safe */ delqueue(it); run_queue(&bounceq); /* NOTREACHED */ fail: syslog(LOG_CRIT, "error creating bounce: %m"); delqueue(it); exit(1); }
int main(int argc, char *argv[]) { int i; char *displayname = NULL; Bool all_screens = False; Bool verbose = False; xcb_connection_t *dpy; const xcb_setup_t *setup; int screen_number = 0; int maxcmdlen = 10000; ProgramName = argv[0]; for (i = 1; i < argc; i++) { char *arg = argv[i]; if (arg[0] == '-') { char *cp; switch (arg[1]) { case 'd': /* -display dpyname */ if (++i >= argc) usage (); displayname = argv[i]; continue; case 'm': /* -max maxcmdlen */ if (++i >= argc) usage (); maxcmdlen = atoi (argv[i]); continue; } for (cp = &arg[1]; *cp; cp++) { switch (*cp) { case 'a': /* -all */ all_screens = True; continue; case 'l': /* -long */ verbose = True; continue; default: usage (); } } } else { usage (); } } dpy = xcb_connect(displayname, &screen_number); if (xcb_connection_has_error(dpy)) { char *name = displayname; if (!name) name = getenv("DISPLAY"); if (!name) name = ""; fprintf (stderr, "%s: unable to open display \"%s\"\r\n", ProgramName, name); exit (1); } init_atoms(dpy); setup = xcb_get_setup(dpy); if (all_screens) { xcb_screen_iterator_t screen; screen = xcb_setup_roots_iterator(setup); do { lookat(dpy, screen.data->root, verbose, maxcmdlen); xcb_screen_next(&screen); } while (screen.rem); } else { xcb_screen_iterator_t screen; screen = xcb_setup_roots_iterator(setup); for (i = 0; i < screen_number; i++) xcb_screen_next(&screen); lookat (dpy, screen.data->root, verbose, maxcmdlen); } run_queue(); xcb_disconnect(dpy); exit (0); }