Changeset 4107


Ignore:
Timestamp:
Jan 9, 2014 10:00:17 AM (10 years ago)
Author:
ldelgass
Message:

Add command-line options to nanovis/geovis/vtkvis servers to allow setting
file descriptors to use for client IO (i.e. which fds are used by nanoscale
to dup the socket). Must be 0-4 and check that trace log fd isn't used for
client IO.

Location:
trunk/packages/vizservers
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/geovis/RenderServer.cpp

    r4105 r4107  
    444444    // Ignore SIGPIPE.  **Is this needed? **
    445445    signal(SIGPIPE, SIG_IGN);
     446
     447    //const char *resourcePath = NULL;
     448    while (1) {
     449        int c = getopt(argc, argv, "p:i:o:");
     450        if (c == -1) {
     451            break;
     452        }
     453        switch (c) {
     454        case 'p':
     455            //resourcePath = optarg;
     456            break;
     457        case 'i': {
     458            int fd = atoi(optarg);
     459            if (fd >=0 && fd < 5) {
     460                g_fdIn = fd;
     461            }
     462        }
     463            break;
     464        case 'o': {
     465            int fd = atoi(optarg);
     466            if (fd >=0 && fd < 5) {
     467                g_fdOut = fd;
     468            }
     469        }
     470            break;
     471        case '?':
     472            break;
     473        default:
     474            return 1;
     475        }
     476    }
     477
    446478    initService();
    447479    initLog();
     
    451483
    452484    TRACE("Starting GeoVis Server");
     485
     486    // Sanity check: log descriptor can't be used for client IO
     487    if (fileno(g_fLog) == g_fdIn) {
     488        ERROR("Invalid input file descriptor");
     489        return 1;
     490    }
     491    if (fileno(g_fLog) == g_fdOut) {
     492        ERROR("Invalid output file descriptor");
     493        return 1;
     494    }
     495    TRACE("File descriptors: in %d out %d log %d", g_fdIn, g_fdOut, fileno(g_fLog));
    453496
    454497    /* This synchronizes the client with the server, so that the client
  • trunk/packages/vizservers/nanovis/nanovisServer.cpp

    r4105 r4107  
    464464    // Ignore SIGPIPE.  **Is this needed? **
    465465    signal(SIGPIPE, SIG_IGN);
     466
     467    const char *resourcePath = NULL;
     468    while (1) {
     469        static struct option long_options[] = {
     470            {"debug",   no_argument,       NULL, 'd'},
     471            {"path",    required_argument, NULL, 'p'},
     472            {0, 0, 0, 0}
     473        };
     474        int option_index = 0;
     475        int c = getopt_long(argc, argv, "dp:i:o:", long_options, &option_index);
     476        if (c == -1) {
     477            break;
     478        }
     479        switch (c) {
     480        case 'd':
     481            NanoVis::debugFlag = true;
     482            break;
     483        case 'p':
     484            resourcePath = optarg;
     485            break;
     486        case 'i': {
     487            int fd = atoi(optarg);
     488            if (fd >=0 && fd < 5) {
     489                g_fdIn = fd;
     490            }
     491        }
     492            break;
     493        case 'o': {
     494            int fd = atoi(optarg);
     495            if (fd >=0 && fd < 5) {
     496                g_fdOut = fd;
     497            }
     498        }
     499            break;
     500        case '?':
     501            break;
     502        default:
     503            return 1;
     504        }
     505    }
     506
    466507    initService();
    467508    initLog();
     
    471512
    472513    TRACE("Starting NanoVis Server");
     514    if (NanoVis::debugFlag) {
     515        TRACE("Debugging on");
     516    }
     517
     518    // Sanity check: log descriptor can't be used for client IO
     519    if (fileno(g_fLog) == g_fdIn) {
     520        ERROR("Invalid input file descriptor");
     521        return 1;
     522    }
     523    if (fileno(g_fLog) == g_fdOut) {
     524        ERROR("Invalid output file descriptor");
     525        return 1;
     526    }
     527    TRACE("File descriptors: in %d out %d log %d", g_fdIn, g_fdOut, fileno(g_fLog));
    473528
    474529    /* This synchronizes the client with the server, so that the client
     
    509564    glutReshapeFunc(reshape);
    510565
    511     const char *path = NULL;
    512     char *newPath = NULL;
    513 
    514     while (1) {
    515         static struct option long_options[] = {
    516             {"debug",   no_argument,       NULL, 'd'},
    517             {"path",    required_argument, NULL, 'p'},
    518             {0, 0, 0, 0}
    519         };
    520         int option_index = 0;
    521         int c = getopt_long(argc, argv, "dp:", long_options, &option_index);
    522         if (c == -1) {
    523             break;
    524         }
    525         switch (c) {
    526         case 'd':
    527             TRACE("Debugging on");
    528             NanoVis::debugFlag = true;
    529             break;
    530         case 'p':
    531             TRACE("Resource path: '%s'", optarg);
    532             path = optarg;
    533             break;
    534         case '?':
    535             break;
    536         default:
    537             fprintf(stderr,"unknown option '%c'.\n", c);
    538             return 1;
    539         }
    540     }
    541     if (path == NULL) {
     566    char *newResourcePath = NULL;
     567    if (resourcePath == NULL) {
    542568        char *p;
    543569
    544570        // See if we can derive the path from the location of the program.
    545571        // Assume program is in the form <path>/bin/nanovis.
    546         path = argv[0];
    547         p = strrchr((char *)path, '/');
     572        resourcePath = argv[0];
     573        p = strrchr((char *)resourcePath, '/');
    548574        if (p != NULL) {
    549575            *p = '\0';
    550             p = strrchr((char *)path, '/');
     576            p = strrchr((char *)resourcePath, '/');
    551577        }
    552578        if (p == NULL) {
     
    555581        }
    556582        *p = '\0';
    557         newPath = new char[(strlen(path) + 15) * 2 + 1];
    558         sprintf(newPath, "%s/lib/shaders:%s/lib/resources", path, path);
    559         path = newPath;
    560         TRACE("No resource path specified, using: %s", path);
     583        newResourcePath = new char[(strlen(resourcePath) + 15) * 2 + 1];
     584        sprintf(newResourcePath, "%s/lib/shaders:%s/lib/resources", resourcePath, resourcePath);
     585        resourcePath = newResourcePath;
     586        TRACE("No resource path specified, using: %s", resourcePath);
     587    } else {
     588        TRACE("Resource path: '%s'", resourcePath);
    561589    }
    562590
    563591    FilePath::getInstance()->setWorkingDirectory(argc, (const char**) argv);
    564592
    565     if (!NanoVis::init(path)) {
     593    if (!NanoVis::init(resourcePath)) {
    566594        exitService(1);
    567595    }
    568     if (newPath != NULL) {
    569         delete [] newPath;
     596    if (newResourcePath != NULL) {
     597        delete [] newResourcePath;
    570598    }
    571599
  • trunk/packages/vizservers/vtkvis/RenderServer.cpp

    r4105 r4107  
    492492    // Ignore SIGPIPE.  **Is this needed? **
    493493    signal(SIGPIPE, SIG_IGN);
     494
     495    while (1) {
     496        int c = getopt(argc, argv, "i:o:");
     497        if (c == -1) {
     498            break;
     499        }
     500        switch (c) {
     501        case 'i': {
     502            int fd = atoi(optarg);
     503            if (fd >=0 && fd < 5) {
     504                g_fdIn = fd;
     505            }
     506        }
     507            break;
     508        case 'o': {
     509            int fd = atoi(optarg);
     510            if (fd >=0 && fd < 5) {
     511                g_fdOut = fd;
     512            }
     513        }
     514            break;
     515        case '?':
     516            break;
     517        default:
     518            return 1;
     519        }
     520    }
     521
    494522    initService();
    495523    initLog();
     
    499527
    500528    TRACE("Starting VTKVis Server");
     529
     530    // Sanity check: log descriptor can't be used for client IO
     531    if (fileno(g_fLog) == g_fdIn) {
     532        ERROR("Invalid input file descriptor");
     533        return 1;
     534    }
     535    if (fileno(g_fLog) == g_fdOut) {
     536        ERROR("Invalid output file descriptor");
     537        return 1;
     538    }
     539    TRACE("File descriptors: in %d out %d log %d", g_fdIn, g_fdOut, fileno(g_fLog));
    501540
    502541#ifdef WANT_TRACE
Note: See TracChangeset for help on using the changeset viewer.