Changeset 4794 for nanovis


Ignore:
Timestamp:
Nov 26, 2014, 4:40:30 AM (5 years ago)
Author:
ldelgass
Message:

Don't add extra pid to stats log line

Location:
nanovis/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • nanovis/trunk/Command.cpp

    r4488 r4794  
    846846    /* Use the initial client key value pairs as the parts for a generating
    847847     * a unique file name. */
    848     int f = getStatsFile(interp, objv[1]);
     848    int f = getStatsFile(objv[1]);
    849849    if (f < 0) {
    850850        Tcl_AppendResult(interp, "can't open stats file: ",
     
    867867        objPtr = Tcl_NewStringObj("pid", 3);
    868868        Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
    869         Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewIntObj(getpid()));
     869        Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewLongObj((long)g_stats.pid));
    870870        /* host */
    871871        objPtr = Tcl_NewStringObj("host", 4);
  • nanovis/trunk/nanovisServer.cpp

    r4111 r4794  
    8484    std::ostringstream oss;
    8585    oss << "nv>ok -token " << g_stats.nCommands <<  "\n";
    86     size_t numBytes = oss.str().length();
     86    std::string str = oss.str();
     87    size_t numBytes = str.length();
    8788
    8889    TRACE("Sending OK for commands through %lu", g_stats.nCommands);
    8990#ifdef USE_THREADS
    90     queueResponse(oss.str().c_str(), numBytes, Response::VOLATILE, Response::OK);
     91    queueResponse(str.c_str(), numBytes, Response::VOLATILE, Response::OK);
    9192#else
    92     if (write(g_fdOut, oss.str().c_str(), numBytes) < 0) {
     93    if (write(g_fdOut, str.c_str(), numBytes) < 0) {
    9394        ERROR("write failed: %s", strerror(errno));
    9495        return -1;
     
    105106
    106107int
    107 nv::getStatsFile(Tcl_Interp *interp, Tcl_Obj *objPtr)
     108nv::getStatsFile(Tcl_Obj *objPtr)
    108109{
    109110    Tcl_DString ds;
    110     Tcl_Obj **objv;
    111     int objc;
    112     int i;
    113111    char fileName[33];
     112    char pidstr[200];
    114113    const char *path;
    115114    md5_state_t state;
     
    121120        return g_statsFile;
    122121    }
    123     if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) {
    124         return -1;
    125     }
    126     Tcl_ListObjAppendElement(interp, objPtr, Tcl_NewStringObj("pid", 3));
    127     Tcl_ListObjAppendElement(interp, objPtr, Tcl_NewIntObj(getpid()));
     122    /* By itself the client's key/value pairs aren't unique.  Add in the
     123     * process id of this render server. */
     124    sprintf(pidstr, "%ld", (long)g_stats.pid);
     125
     126    /* Create an md5 hash of the key/value pairs and use it as the file name. */
    128127    string = Tcl_GetStringFromObj(objPtr, &length);
    129 
    130128    md5_init(&state);
    131     md5_append(&state, (const md5_byte_t *)string, length);
     129    md5_append(&state, (const md5_byte_t *)string, strlen(string));
     130    md5_append(&state, (const md5_byte_t *)pidstr, strlen(pidstr));
    132131    md5_finish(&state, digest);
    133     for (i = 0; i < 16; i++) {
     132    for (int i = 0; i < 16; i++) {
    134133        sprintf(fileName + i * 2, "%02x", digest[i]);
    135134    }
     
    208207    /* pid */
    209208    Tcl_DStringAppendElement(&ds, "pid");
    210     sprintf(buf, "%d", getpid());
     209    sprintf(buf, "%ld", (long)g_stats.pid);
    211210    Tcl_DStringAppendElement(&ds, buf);
    212211    /* host */
     
    273272    }
    274273    Tcl_DStringAppend(&ds, "\n", -1);
    275     f = getStatsFile(NULL, NULL);
     274    f = getStatsFile(NULL);
    276275    result = writeToStatsFile(f, Tcl_DStringValue(&ds),
    277276                              Tcl_DStringLength(&ds));
     
    510509
    511510    memset(&g_stats, 0, sizeof(g_stats));
     511    g_stats.pid = getpid();
    512512    gettimeofday(&g_stats.start, NULL);
    513513
  • nanovis/trunk/nanovisServer.h

    r4105 r4794  
    5151
    5252#ifdef KEEPSTATS
    53     extern int getStatsFile(Tcl_Interp *interp, Tcl_Obj *objPtr);
     53    extern int getStatsFile(Tcl_Obj *objPtr);
    5454    extern int writeToStatsFile(int f, const char *s, size_t length);
    5555#endif
Note: See TracChangeset for help on using the changeset viewer.