Changeset 3377
- Timestamp:
- Feb 27, 2013 11:34:13 PM (10 years ago)
- Location:
- trunk/packages/vizservers
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/Command.cpp
r3376 r3377 747 747 * ClientInfoCmd -- 748 748 * 749 * Log initial values to stats file. 750 * 751 * clientinfo path list 749 * Log initial values to stats file. The first time this is called 750 * "render_start" is written into the stats file. Afterwards, it 751 * is "render_info". 752 * 753 * clientinfo list 752 754 */ 753 755 static int … … 762 764 static int first = 1; 763 765 764 if (objc != 3) {766 if (objc != 2) { 765 767 Tcl_AppendResult(interp, "wrong # of arguments: should be \"", 766 Tcl_GetString(objv[0]), " pathlist\"", (char *)NULL);768 Tcl_GetString(objv[0]), " list\"", (char *)NULL); 767 769 return TCL_ERROR; 768 770 } 769 771 #ifdef KEEPSTATS 770 const char *path;771 772 path = Tcl_GetString(objv[1]);773 if ( NanoVis::openStatsFile(path)< 0) {772 /* Use the initial client key value pairs as the parts for a generating 773 * a unique file name. */ 774 f = NanoVis::getStatsFile(objv[1]); 775 if (f < 0) { 774 776 Tcl_AppendResult(interp, "can't open stats file: ", 775 Tcl_PosixError(interp), (char *)NULL);777 Tcl_PosixError(interp), (char *)NULL); 776 778 return TCL_ERROR; 777 779 } … … 806 808 Tcl_DStringAppendElement(&ds, buf); 807 809 /* Client arguments. */ 808 if (Tcl_ListObjGetElements(interp, objv[ 2], &numElems, &elems) != TCL_OK) {810 if (Tcl_ListObjGetElements(interp, objv[1], &numElems, &elems) != TCL_OK) { 809 811 return TCL_ERROR; 810 812 } … … 815 817 816 818 #ifdef KEEPSTATS 817 result = NanoVis::writeToStatsFile( Tcl_DStringValue(&ds),819 result = NanoVis::writeToStatsFile(f, Tcl_DStringValue(&ds), 818 820 Tcl_DStringLength(&ds)); 819 821 #else -
trunk/packages/vizservers/nanovis/Makefile.in
r3362 r3377 59 59 LD_RUN_PATH = $(libdir):@LD_RPATH@ 60 60 61 SVN_VERSION = $(shell svnversion) 62 61 63 LIBS = \ 62 64 $(RP_LIB_SPEC) \ … … 91 93 CFLAGS = @CFLAGS@ 92 94 EXTRA_CFLAGS = -Wall 93 DEFINES = 95 DEFINES = -DSVN_VERSION=\"$(SVN_VERSION)\" 94 96 ifdef USE_POINTSET_RENDERER 95 97 DEFINES +=-DUSE_POINTSET_RENDERER … … 145 147 dxReader.o \ 146 148 dxReaderCommon.o \ 147 nanovis.o 149 nanovis.o \ 150 md5.o 148 151 149 152 resources = \ -
trunk/packages/vizservers/nanovis/nanovis.cpp
r3376 r3377 324 324 325 325 int 326 NanoVis:: openStatsFile(const char *path)326 NanoVis::getStatsFile(Tcl_Obj *objPtr) 327 327 { 328 328 Tcl_DString ds; 329 char **argv;330 int argc;329 Tcl_Obj **objv; 330 int objc; 331 331 int i; 332 const char *fileName; 333 char string[200]; 334 332 char fileName[33]; 333 md5_state_t state; 334 md5_byte_t digest[16]; 335 char *string; 336 337 if (objPtr == NULL) { 338 return statsFile; 339 } 340 if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) { 341 return -1; 342 } 343 Tcl_ListObjAppendElement(interp, objPtr, Tcl_NewStringObj("pid", 3)); 344 Tcl_ListObjAppendElement(interp, objPtr, Tcl_NewIntObj(getpid())); 345 string = Tcl_GetStringFromObj(objPtr, &length); 346 347 md5_init(&state); 348 md5_append(&state, (const md5_byte_t *)string, length); 349 md5_finish(&state, digest); 350 for (i = 0; i < 16; i++) { 351 sprintf(fileName + i * 2, "%02x", digest[i]); 352 } 335 353 Tcl_DStringInit(&ds); 336 354 Tcl_DStringAppend(&ds, STATSDIR, -1); 337 SplitPath(path, &argc, &argv);338 for (i = 0; i < argc; i++) {339 char *p;340 341 Tcl_DStringAppend(&ds, "/", 1);342 Tcl_DStringAppend(&ds, argv[i], -1);343 p = Tcl_DStringValue(&ds);344 if (access(p, X_OK) != 0) {345 mkdir(p, 0770);346 }347 }348 355 Tcl_DStringAppend(&ds, "/", 1); 349 sprintf(string, "%d", getpid()); 350 Tcl_DStringAppend(&ds, string, -1); 351 fileName = Tcl_DStringValue(&ds); 352 free(argv); 353 statsFile = open(fileName, O_EXCL | O_CREAT | O_WRONLY, 0600); 356 Tcl_DStringAppend(&dsm fileName, 32); 357 path = Tcl_DStringValue(&ds); 358 359 statsFile = open(path, O_EXCL | O_CREAT | O_WRONLY, 0600); 354 360 Tcl_DStringFree(&ds); 355 361 if (statsFile < 0) { … … 361 367 362 368 int 363 NanoVis::writeToStatsFile( const char *s, size_t length)364 { 365 ssize_t numWritten;366 367 if (statsFile >= 0) { 368 numWritten = write( statsFile, s, length);369 NanoVis::writeToStatsFile(int f, const char *s, size_t length) 370 { 371 if (f >= 0) { 372 ssize_t numWritten; 373 374 numWritten = write(f, s, length); 369 375 if (numWritten == (ssize_t)length) { 370 close(dup( statsFile));376 close(dup(f)); 371 377 } 372 378 } … … 381 387 Tcl_DString ds; 382 388 int result; 389 int f; 383 390 384 391 { … … 483 490 } 484 491 Tcl_DStringAppend(&ds, "\n", -1); 485 result = NanoVis::writeToStatsFile(Tcl_DStringValue(&ds), 492 f = NanoVis::getStatsFile(NULL); 493 result = NanoVis::writeToStatsFile(f, Tcl_DStringValue(&ds), 486 494 Tcl_DStringLength(&ds)); 495 close(f); 487 496 Tcl_DStringFree(&ds); 488 497 return result; … … 2004 2013 NanoVis::stdin = stdin; 2005 2014 2006 fprintf(stdout, "NanoVis %s \n", NANOVIS_VERSION);2015 fprintf(stdout, "NanoVis %s (build %s)\n", NANOVIS_VERSION, SVN_VERSION); 2007 2016 fflush(stdout); 2008 2017 -
trunk/packages/vizservers/nanovis/nanovis.h
r3376 r3377 18 18 19 19 #include <tcl.h> 20 20 #include <md5.h> 21 21 #include <GL/glew.h> 22 22 … … 97 97 98 98 #ifdef KEEPSTATS 99 static int openStatsFile(const char *path);100 static int writeToStatsFile( const char *s, size_t length);99 static int getStatsFile(Tcl_Obj *objPtr); 100 static int writeToStatsFile(int f, const char *s, size_t length); 101 101 #endif 102 102 static void ppmWrite(const char *prefix); -
trunk/packages/vizservers/pymolproxy/Makefile.in
r2665 r3377 30 30 31 31 FILES = pymolproxy pymolproxy2 32 PROXY_OBJS = pymolproxy.o 33 PROXY2_OBJS = pymolproxy2.o 32 PROXY_OBJS = pymolproxy.o md5.o 33 PROXY2_OBJS = pymolproxy2.o md5.o 34 34 LIBS = $(TCL_LIB_SPEC) \ 35 35 -Wl,-rpath,$(RP_LIB_DIR) -
trunk/packages/vizservers/pymolproxy/pymolproxy2.c
r3376 r3377 78 78 #include <tcl.h> 79 79 #include <pthread.h> 80 #include <md5.h> 80 81 81 82 #undef INLINE … … 576 577 577 578 static int 578 OpenStatsFile(const char *path)579 GetStatsFile(const char *string) 579 580 { 580 581 Tcl_DString ds; 581 char **argv;582 int argc;583 582 int i; 584 const char *fileName; 585 char string[200]; 586 587 if (access(STATSDIR, X_OK) != 0) { 588 mkdir(STATSDIR, 0770); 589 } 590 SplitPath(path, &argc, &argv); 583 char fileName[33]; 584 const char *path; 585 int length; 586 char pidstr[200]; 587 md5_state_t state; 588 md5_byte_t digest[16]; 589 590 if (string == NULL) { 591 return statsFile; 592 } 593 /* By itself the client's key/value pairs aren't unique. Add in the 594 * process id of this render server. */ 591 595 Tcl_DStringInit(&ds); 596 Tcl_DStringAppend(&ds, string, -1); 597 Tcl_DStringAppendElement(&ds, "pid", 3); 598 sprintf(pidstr, "%d", getpid()); 599 Tcl_DStringAppendElement(&ds, pidstr, -1); 600 601 /* Create a md5 hash of the key/value pairs and use it as the file name. */ 602 string = Tcl_DStringValue(&ds); 603 length = strlen(string); 604 md5_init(&state); 605 md5_append(&state, (const md5_byte_t *)string, length); 606 md5_finish(&state, digest); 607 for (i = 0; i < 16; i++) { 608 sprintf(fileName + i * 2, "%02x", digest[i]); 609 } 610 Tcl_DStringLength(&ds, 0); 592 611 Tcl_DStringAppend(&ds, STATSDIR, -1); 593 for (i = 0; i < argc; i++) {594 char *p;595 596 Tcl_DStringAppend(&ds, "/", 1);597 Tcl_DStringAppend(&ds, argv[i], -1);598 p = Tcl_DStringValue(&ds);599 if (access(p, X_OK) != 0) {600 mkdir(p, 0770);601 }602 }603 612 Tcl_DStringAppend(&ds, "/", 1); 604 sprintf(string, "%d", getpid()); 605 Tcl_DStringAppend(&ds, string, -1); 606 fileName = Tcl_DStringValue(&ds); 607 free(argv); 608 statsFile = open(fileName, O_CREAT | O_EXCL | O_WRONLY, 0600); 613 Tcl_DStringAppend(&ds, fileName, 32); 614 path = Tcl_DStringValue(&ds); 615 616 statsFile = open(path, O_EXCL | O_CREAT | O_WRONLY, 0600); 609 617 Tcl_DStringFree(&ds); 610 618 if (statsFile < 0) { … … 616 624 617 625 static int 618 WriteToStatsFile(const char *s, size_t length) 619 { 620 ssize_t numWritten; 621 622 if (statsFile >= 0) { 623 numWritten = write(statsFile, s, length); 626 WriteToStatsFile(int f, const char *s, size_t length) 627 { 628 629 if (f >= 0) { 630 ssize_t numWritten; 631 632 numWritten = write(f, s, length); 624 633 if (numWritten == (ssize_t)length) { 625 close(dup( statsFile));634 close(dup(f)); 626 635 } 627 636 } … … 738 747 } 739 748 Tcl_DStringAppend(&ds, "\n", -1); 740 result = WriteToStatsFile(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); 749 f = GetStatsFile(NULL); 750 result = WriteToStatsFile(f, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); 741 751 Tcl_DStringFree(&ds); 752 close(f); 742 753 return result; 743 754 } … … 934 945 char buf[BUFSIZ]; 935 946 static int first = 1; 936 937 if (argc != 3) { 947 int f; 948 949 if (argc != 2) { 938 950 Tcl_AppendResult(interp, "wrong # of arguments: should be \"", argv[0], 939 " pathlist\"", (char *)NULL);951 " list\"", (char *)NULL); 940 952 return TCL_ERROR; 941 953 } 942 if ((statsFile == -1) && (OpenStatsFile(argv[1]) < 0)) { 954 /* Use the initial client key value pairs as the parts for a generating 955 * a unique file name. */ 956 f = GetStatsFile(argv[1]); 957 if (f < 0) { 943 958 Tcl_AppendResult(interp, "can't open stats file: ", 944 959 Tcl_PosixError(interp), (char *)NULL); 945 960 return TCL_ERROR; 946 961 } … … 983 998 free(elems); 984 999 Tcl_DStringAppend(&ds, "\n", 1); 985 result = WriteToStatsFile( Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));1000 result = WriteToStatsFile(f, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); 986 1001 Tcl_DStringFree(&ds); 987 1002 return result;
Note: See TracChangeset
for help on using the changeset viewer.