Beispiel #1
0
    // a wrapper around the helper function distributeInfo
    int distributePyInfo( const PyEntity& ent, const python::object& py_info,
			  const PyService& serv, bool exclude )
    {
      boost::shared_ptr<PyInfo> info;
      theInfoManager().createInfo( info );
      //info->fData = &py_info;
      info->setData( py_info );
      //info->fData =  boost::make_shared<boost::python::object>(py_info);
      if ( exclude )
	return distributeInfo( ent, info, &serv );
      else
	return distributeInfo( ent, info );
    }
Beispiel #2
0
static void *listenToClients(void *val)
{
    /* Gather the information from all remote processes via sockets. */
    unsigned int i;

    if (!args.np) exit(1);

    clients = malloc(args.np * sizeof(*clients));

    if (!clients) {
	fprintf(stderr, "%s: No memory\n", __func__);
	exit(1);
    }

    for (i=0; i<args.np; i++) {
	clients[i].pid = 0;
    }

    collectInfo(args.sock, args.np, args.magic, args.verbose);

    if (args.verbose) {
	printf("Received data from all %u MPI processes.\n", args.np);
    }

    /* Send the Port ID/Board ID mapping to all remote processes. */
    distributeInfo(args.np, args.verbose);

    if (args.verbose) {
	printf("Data sent to all processes.\n");
    }

    /* Keep the first socket opened for abort messages. */
    while (1) {
	int sock, count, ret;
	unsigned int thismagic;
	char buf[256];

	sock = accept(args.sock, NULL, 0);

	count = recv(sock, buf, sizeof(buf), 0);
	if (count < 0) {
	    int eno = errno;
	    fprintf(stderr, "%s: recv(): %s\n keep listening...\n", __func__,
		    strerror(eno));
	    close(sock);
	    continue;
	}

	ret = sscanf(buf, "<<<ABORT_%u_ABORT>>>", &thismagic);

	if (ret != 1) {
	    fprintf(stderr,
		    "Received spurious abort message, keep listening...\n");
	    close(sock);
	    continue;
	}

	/* Check the magic number. */
	if (thismagic != args.magic) {
	    fprintf(stderr, "Received bad magic number in abort message!\n");
	    close(sock);
	    continue;
	}

	close(sock);
	close(args.sock);

	if (args.verbose) {
	    printf("Received valid abort message !\n");
	}

	exit (0);
    }
}