Changeset 6398 for pymolproxy


Ignore:
Timestamp:
Jun 16, 2016 7:49:57 PM (8 years ago)
Author:
ldelgass
Message:

Fix stats time entries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pymolproxy/trunk/pymolproxy.c

    r5963 r6398  
    623623ServerStats(int code)
    624624{
    625     double start, finish;
     625    double session_time;
    626626    char buf[BUFSIZ];
    627627    Tcl_DString ds;
    628628    int result;
    629629    int f;
    630 
    631     {
    632         struct timeval tv;
    633 
    634         /* Get ending time.  */
    635         gettimeofday(&tv, NULL);
    636         finish = CVT2SECS(tv);
    637         tv = stats.start;
    638         start = CVT2SECS(tv);
    639     }
     630    struct timeval now;
     631
     632    /* Get ending time.  */
     633    gettimeofday(&now, NULL);
     634    session_time = CVT2SECS(now) - CVT2SECS(stats.start);
     635
    640636    /*
    641637     * Session information:
     
    643639     *   - Process ID
    644640     *   - Hostname where server is running
    645      *   - Start date of session
    646      *   - Start date of session in seconds
     641     *   - Stop date of session
     642     *   - Stop date of session in seconds
    647643     *   - Number of frames returned
    648644     *   - Number of bytes total returned (in frames)
     
    674670    /* date */
    675671    Tcl_DStringAppendElement(&ds, "date");
    676     strcpy(buf, ctime(&stats.start.tv_sec));
     672    strcpy(buf, ctime(&now.tv_sec));
    677673    buf[strlen(buf) - 1] = '\0';
    678674    Tcl_DStringAppendElement(&ds, buf);
    679675    /* date_secs */
    680676    Tcl_DStringAppendElement(&ds, "date_secs");
    681     sprintf(buf, "%ld", stats.start.tv_sec);
     677    sprintf(buf, "%ld", now.tv_sec);
    682678    Tcl_DStringAppendElement(&ds, buf);
    683679    /* num_frames */
     
    699695    /* session_time */
    700696    Tcl_DStringAppendElement(&ds, "session_time");
    701     sprintf(buf, "%g", finish - start);
     697    sprintf(buf, "%g", session_time);
    702698    Tcl_DStringAppendElement(&ds, buf);
    703699    /* status */
     
    927923    char buf[BUFSIZ];
    928924    static int first = 1;
    929     int f;
     925    int fd;
    930926
    931927    if (argc != 2) {
     
    936932    /* Use the initial client key value pairs as the parts for a generating
    937933     * a unique file name. */
    938     f = GetStatsFile(argv[1]);
    939     if (f < 0) {
     934    fd = GetStatsFile(argv[1]);
     935    if (fd < 0) {
    940936        Tcl_AppendResult(interp, "can't open stats file: ",
    941937                         Tcl_PosixError(interp), (char *)NULL);
     
    958954        buf[BUFSIZ-1] = '\0';
    959955        Tcl_DStringAppendElement(&ds, buf);
     956        /* date */
     957        Tcl_DStringAppendElement(&ds, "date");
     958        strcpy(buf, ctime(&stats.start.tv_sec));
     959        buf[strlen(buf) - 1] = '\0';
     960        Tcl_DStringAppendElement(&ds, buf);
     961        /* date_secs */
     962        Tcl_DStringAppendElement(&ds, "date_secs");
     963        sprintf(buf, "%ld", stats.start.tv_sec);
     964        Tcl_DStringAppendElement(&ds, buf);
    960965    } else {
     966        struct timeval now;
    961967        Tcl_DStringAppendElement(&ds, "render_info");
    962     }
    963     /* date */
    964     Tcl_DStringAppendElement(&ds, "date");
    965     strcpy(buf, ctime(&stats.start.tv_sec));
    966     buf[strlen(buf) - 1] = '\0';
    967     Tcl_DStringAppendElement(&ds, buf);
    968     /* date_secs */
    969     Tcl_DStringAppendElement(&ds, "date_secs");
    970     sprintf(buf, "%ld", stats.start.tv_sec);
    971     Tcl_DStringAppendElement(&ds, buf);
    972 
     968        gettimeofday(&now, NULL);
     969        /* date */
     970        Tcl_DStringAppendElement(&ds, "date");
     971        strcpy(buf, ctime(&now.tv_sec));
     972        buf[strlen(buf) - 1] = '\0';
     973        Tcl_DStringAppendElement(&ds, buf);
     974        /* date_secs */
     975        Tcl_DStringAppendElement(&ds, "date_secs");
     976        sprintf(buf, "%ld", now.tv_sec);
     977        Tcl_DStringAppendElement(&ds, buf);
     978    }
    973979    /* Client arguments. */
    974980    if (Tcl_SplitList(interp, argv[1], &numElems, &elems) != TCL_OK) {
     
    980986    free(elems);
    981987    Tcl_DStringAppend(&ds, "\n", 1);
    982     result = WriteToStatsFile(f, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
     988    result = WriteToStatsFile(fd, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
    983989    Tcl_DStringFree(&ds);
    984990    return result;
Note: See TracChangeset for help on using the changeset viewer.