Changeset 4792


Ignore:
Timestamp:
Nov 26, 2014 12:26:51 AM (6 years ago)
Author:
ldelgass
Message:

Don't add extra pid to stats log line

Location:
vtkvis/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • vtkvis/trunk/RenderServer.cpp

    r4615 r4792  
    203203    std::ostringstream oss;
    204204    oss << "nv>ok -token " << g_stats.nCommands <<  "\n";
    205     int nBytes = oss.str().length();
     205    std::string str = oss.str();
     206    int nBytes = str.length();
    206207
    207208    TRACE("Sending OK for commands through %lu", g_stats.nCommands);
    208209#ifdef USE_THREADS
    209     queueResponse(clientData, oss.str().c_str(), nBytes, Response::VOLATILE, Response::OK);
    210 #else
    211     if (write(fdOut, oss.str().c_str(), nBytes) < 0) {
     210    queueResponse(clientData, str.c_str(), nBytes, Response::VOLATILE, Response::OK);
     211#else
     212    if (write(fdOut, str.c_str(), nBytes) < 0) {
    212213        ERROR("write failed: %s", strerror(errno));
    213214        return -1;
     
    218219
    219220int
    220 VtkVis::getStatsFile(Tcl_Interp *interp, Tcl_Obj *objPtr)
    221 {
    222     Tcl_Obj **objv;
    223     int objc;
    224     int i;
     221VtkVis::getStatsFile(Tcl_Obj *objPtr)
     222{
    225223    char fileName[33];
     224    char pidstr[200];
    226225    md5_state_t state;
    227226    md5_byte_t digest[16];
     
    232231        return g_statsFile;
    233232    }
    234     if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) {
    235         return -1;
    236     }
    237     Tcl_ListObjAppendElement(interp, objPtr, Tcl_NewStringObj("pid", 3));
    238     Tcl_ListObjAppendElement(interp, objPtr, Tcl_NewIntObj(getpid()));
     233    /* By itself the client's key/value pairs aren't unique.  Add in the
     234     * process id of this render server. */
     235    sprintf(pidstr, "%ld", (long)g_stats.pid);
     236
     237    /* Create an md5 hash of the key/value pairs and use it as the file name. */
    239238    string = Tcl_GetStringFromObj(objPtr, &length);
    240 
    241239    md5_init(&state);
    242     md5_append(&state, (const md5_byte_t *)string, length);
     240    md5_append(&state, (const md5_byte_t *)string, strlen(string));
     241    md5_append(&state, (const md5_byte_t *)pidstr, strlen(pidstr));
    243242    md5_finish(&state, digest);
    244     for (i = 0; i < 16; i++) {
     243    for (int i = 0; i < 16; i++) {
    245244        sprintf(fileName + i * 2, "%02x", digest[i]);
    246245    }
     
    318317    /* pid */
    319318    Tcl_DStringAppendElement(&ds, "pid");
    320     sprintf(buf, "%d", getpid());
     319    sprintf(buf, "%ld", (long)g_stats.pid);
    321320    Tcl_DStringAppendElement(&ds, buf);
    322321    /* host */
     
    391390    }
    392391    Tcl_DStringAppend(&ds, "\n", -1);
    393     f = getStatsFile(NULL, NULL);
     392    f = getStatsFile(NULL);
    394393    result = writeToStatsFile(f, Tcl_DStringValue(&ds),
    395394                              Tcl_DStringLength(&ds));
     
    520519
    521520    memset(&g_stats, 0, sizeof(g_stats));
     521    g_stats.pid = getpid();
    522522    gettimeofday(&g_stats.start, NULL);
    523523
  • vtkvis/trunk/RenderServer.h

    r4738 r4792  
    4949extern int g_statsFile;
    5050extern int writeToStatsFile(int f, const char *s, size_t length);
    51 extern int getStatsFile(Tcl_Interp * interp, Tcl_Obj *objPtr);
     51extern int getStatsFile(Tcl_Obj *objPtr);
    5252
    5353}
  • vtkvis/trunk/RendererCmd.cpp

    r4784 r4792  
    23252325    /* Use the initial client key value pairs as the parts for a generating
    23262326     * a unique file name. */
    2327     int fd = VtkVis::getStatsFile(interp, objv[1]);
     2327    int fd = VtkVis::getStatsFile(objv[1]);
    23282328    if (fd < 0) {
    23292329        Tcl_AppendResult(interp, "can't open stats file: ",
     
    23452345        objPtr = Tcl_NewStringObj("pid", 3);
    23462346        Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
    2347         Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewIntObj(getpid()));
     2347        Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewLongObj((long)VtkVis::g_stats.pid));
    23482348        /* host */
    23492349        objPtr = Tcl_NewStringObj("host", 4);
Note: See TracChangeset for help on using the changeset viewer.