Changeset 4108
- Timestamp:
- Jan 11, 2014, 2:54:59 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/visviewer.tcl
r4100 r4108 283 283 if { [gets $_sid data] <= 0 } { 284 284 set _sid "" 285 puts stderr "reading from server "285 puts stderr "reading from server data=($data)" 286 286 RemoveServerFromList $_serverType $server 287 287 continue 288 }289 # The response should be in the form "serverName major.minor ...".290 set pattern {^[A-Za-z][A-Za-z0-9_]* [0-9]+\.[0-9].*}291 292 while { ![regexp $pattern $data match] } {293 puts stderr "$data"294 if { [gets $_sid data] <= 0 } {295 exit -1296 }297 288 } 298 289 puts stderr "Render server is $data" -
trunk/packages/vizservers/configure
r4060 r4108 629 629 SUBDIRS 630 630 STATSDIR 631 LOGDIR 631 632 LD_RPATH 632 633 CXXCPP … … 718 719 with_tcllib 719 720 with_statsdir 721 with_logsdir 720 722 with_python 721 723 enable_64bit … … 1363 1365 [default=/usr/lib] 1364 1366 --with-statsdir=DIR Write statistics in DIR 1367 --with-logsdir=DIR Write log files in DIR 1365 1368 --with-python=DIR location of python [default=yes] 1366 1369 --with-x use the X Window System … … 2464 2467 else 2465 2468 STATSDIR="/var/tmp/visservers" 2469 fi 2470 2471 2472 2473 # Check whether --with-logsdir was given. 2474 if test "${with_logsdir+set}" = set; then : 2475 withval=$with_logsdir; LOGDIR=$withval 2476 else 2477 LOGDIR="/tmp" 2466 2478 fi 2467 2479 … … 7829 7841 done 7830 7842 7843 for ac_func in mkstemps 7844 do : 7845 ac_fn_cxx_check_func "$LINENO" "mkstemps" "ac_cv_func_mkstemps" 7846 if test "x$ac_cv_func_mkstemps" = xyes; then : 7847 cat >>confdefs.h <<_ACEOF 7848 #define HAVE_MKSTEMPS 1 7849 _ACEOF 7850 7851 fi 7852 done 7853 7831 7854 7832 7855 SUBDIRS="nanoscale pymolproxy" 7856 7833 7857 7834 7858 -
trunk/packages/vizservers/configure.in
r4060 r4108 17 17 [STATSDIR=$withval], 18 18 [STATSDIR="/var/tmp/visservers"]) 19 20 AC_ARG_WITH( 21 [logsdir], 22 [AS_HELP_STRING([--with-logsdir=DIR], 23 [Write log files in DIR])], 24 [LOGDIR=$withval], 25 [LOGDIR="/tmp"]) 19 26 20 27 RP_LANG_PYTHON … … 106 113 107 114 AC_CHECK_FUNCS([accept4]) 115 AC_CHECK_FUNCS([mkstemps]) 108 116 109 117 SUBDIRS="nanoscale pymolproxy" 110 118 111 119 AC_SUBST(LD_RPATH) 120 AC_SUBST(LOGDIR) 112 121 AC_SUBST(STATSDIR) 113 122 AC_SUBST(SUBDIRS) -
trunk/packages/vizservers/nanoscale/Makefile.in
r4050 r4108 30 30 TCL_INC_SPEC = @TCL_INC_SPEC@ 31 31 LD_RUN_PATH = $(libdir) 32 LOGDIR = @LOGDIR@ 33 SVN_VERSION = $(shell svnversion $(srcdir)) 32 34 33 DEFINES = -DSERVERSFILE=\"$(libdir)/renderservers.tcl\" 35 DEFINES = -DSERVERSFILE=\"$(libdir)/renderservers.tcl\" \ 36 -DSVN_VERSION=\"$(SVN_VERSION)\" \ 37 -DLOGDIR=\"$(LOGDIR)\" 34 38 INCLUDES = -I. $(TCL_INC_SPEC) 35 39 LIBS = $(TCL_LIB_SPEC) \ -
trunk/packages/vizservers/nanoscale/config.h.in
r4060 r4108 16 16 #undef HAVE_MEMORY_H 17 17 18 /* Define to 1 if you have the `mkstemps' function. */ 19 #undef HAVE_MKSTEMPS 20 18 21 /* Define to 1 if you have the <netdb.h> header file. */ 19 22 #undef HAVE_NETDB_H … … 21 24 /* Define to 1 if you have the <netinet/in.h> header file. */ 22 25 #undef HAVE_NETINET_IN_H 26 27 /* Define to 1 if you have the <Python.h> header file. */ 28 #undef HAVE_PYTHON_H 23 29 24 30 /* Define to 1 if you have the <stdint.h> header file. */ -
trunk/packages/vizservers/nanoscale/server.c
r4050 r4108 26 26 #ifndef SERVERSFILE 27 27 #define SERVERSFILE "/opt/hubzero/rappture/render/lib/renderservers.tcl" 28 #endif 29 30 #ifndef LOGDIR 31 #define LOGDIR "/tmp" 28 32 #endif 29 33 … … 418 422 if (child == 0) { /* Child process. */ 419 423 int i; 420 int errFd; 421 424 int newFd; 425 char tmpname[200]; 426 422 427 umask(0); 423 428 if ((!debug) && (setsid() < 0)) { … … 431 436 exit(1); 432 437 } 433 434 /* Dup the descriptors and start the server. */ 435 436 if (dup2(f, 0) < 0) { /* Stdin */ 438 /* We could use the same log file for stdout and stderr. 439 * Right now they are separate files. */ 440 441 /* Redirect child's stdout to a log file. */ 442 sprintf(tmpname, "%s/%s-%d-stdout.XXXXXX", LOGDIR, 443 serverPtr->name, getpid()); 444 newFd = mkstemp(tmpname); 445 if (newFd < 0) { 446 ERROR("%s: can't open \"%s\": %s", serverPtr->name, 447 tmpname, strerror(errno)); 448 exit(1); 449 } 450 if (dup2(newFd, 1) < 0) { 451 ERROR("%s: can't dup stdout to \"%s\": %s", 452 serverPtr->name, tmpname, strerror(errno)); 453 exit(1); 454 } 455 /* Redirect child's stderr to a log file. */ 456 sprintf(tmpname, "%s/%s-%d-stderr.XXXXXX", LOGDIR, 457 serverPtr->name, getpid()); 458 newFd = mkstemp(tmpname); 459 if (newFd < 0) { 460 ERROR("%s: can't open \"%s\": %s", serverPtr->name, 461 tmpname, strerror(errno)); 462 exit(1); 463 } 464 if (dup2(newFd, 2) < 0) { 465 ERROR("%s: can't dup stderr to \"%s\": %s", 466 serverPtr->name, tmpname, strerror(errno)); 467 exit(1); 468 } 469 /* Dup the socket to descriptors 3 and 4 */ 470 if (dup2(f, 3) < 0) { /* Stdin */ 437 471 ERROR("%s: can't dup stdin: %s", serverPtr->name, 438 472 strerror(errno)); 439 473 exit(1); 440 474 } 441 if (dup2(f, 1) < 0) { /* Stdout */475 if (dup2(f, 4) < 0) { /* Stdout */ 442 476 ERROR("%s: can't dup stdout: %s", serverPtr->name, 443 477 strerror(errno)); 444 478 exit(1); 445 479 } 446 errFd = open("/dev/null", O_WRONLY, 0600); 447 if (errFd < 0) { 448 ERROR("%s: can't open /dev/null for read/write: %s", 449 serverPtr->name, strerror(errno)); 450 exit(1); 451 } 452 if (dup2(errFd, 2) < 0) { /* Stderr */ 453 ERROR("%s: can't dup stderr for \"%s\": %s", 454 serverPtr->name, strerror(errno)); 455 exit(1); 456 } 457 for(i = 3; i <= FD_SETSIZE; i++) { 480 for(i = 5; i <= FD_SETSIZE; i++) { 458 481 close(i); /* Close all the other descriptors. */ 459 482 } -
trunk/packages/vizservers/nanovis/Command.cpp
r4068 r4108 2237 2237 * available. */ 2238 2238 while (inBufPtr->isLineAvailable() || 2239 (select( 1, &readFds, NULL, NULL, tvPtr) > 0)) {2239 (select(inBufPtr->file()+1, &readFds, NULL, NULL, tvPtr) > 0)) { 2240 2240 size_t numBytes; 2241 2241 unsigned char *buffer; -
trunk/packages/vizservers/nanovis/nanovisServer.cpp
r4107 r4108 46 46 int nv::g_statsFile = -1; ///< Stats output file descriptor. 47 47 48 int nv::g_fdIn = STDIN_FILENO; ///< Input file descriptor 49 int nv::g_fdOut = STDOUT_FILENO; ///< Output file descriptor 48 #define CLIENT_READ (3) 49 #define CLIENT_WRITE (4) 50 int nv::g_fdIn = CLIENT_READ; ///< Input file descriptor 51 int nv::g_fdOut = CLIENT_WRITE; ///< Output file descriptor 50 52 FILE *nv::g_fOut = NULL; ///< Output file handle 51 53 FILE *nv::g_fLog = NULL; ///< Trace logging file handle … … 84 86 std::ostringstream oss; 85 87 oss << "nv>ok -token " << g_stats.nCommands << "\n"; 86 int nBytes = oss.str().length();88 size_t numBytes = oss.str().length(); 87 89 88 90 TRACE("Sending OK for commands through %lu", g_stats.nCommands); 89 91 #ifdef USE_THREADS 90 queueResponse(oss.str().c_str(), n Bytes, Response::VOLATILE, Response::OK);92 queueResponse(oss.str().c_str(), numBytes, Response::VOLATILE, Response::OK); 91 93 #else 92 if (write(g_fdOut, oss.str().c_str(), n Bytes) < 0) {94 if (write(g_fdOut, oss.str().c_str(), numBytes) < 0) { 93 95 ERROR("write failed: %s", strerror(errno)); 94 96 return -1; … … 318 320 initService() 319 321 { 322 // Create a stream associated with the client read file descriptor. If 323 // we're not using a socket (fdopen of descriptor 4 will return NULL), 324 // then use descriptor 1 and stdout respectively. 320 325 g_fOut = fdopen(g_fdOut, "w"); 321 326 // If running without socket, use stdout for debugging 322 if (g_fOut == NULL && g_fdOut != STDOUT_FILENO) {327 if (g_fOut == NULL) { 323 328 g_fdOut = STDOUT_FILENO; 324 g_fOut = fdopen(g_fdOut, "w"); 325 } 326 329 g_fOut = stdout; 330 } 327 331 const char* user = getenv("USER"); 328 332 char* logName = NULL; … … 339 343 strncat(logName, user, strlen(user)); 340 344 } 341 342 // open log and map stderr to log file 345 // Nanoscale automatically redirects stdout and stderr to log files. 343 346 g_fLog = fopen(logName, "w"); 344 347 dup2(fileno(g_fLog), STDERR_FILENO); 345 // If we are writing to socket, map stdout to log346 if (g_fdOut != STDOUT_FILENO) {347 dup2(fileno(g_fLog), STDOUT_FILENO);348 }349 350 fflush(stdout);351 348 352 349 // clean up malloc'd memory … … 531 528 * also be used to supply information about the server (version, memory 532 529 * size, etc). */ 533 fprintf(g_fOut, "NanoVis %s (build %s)\n", NANOVIS_VERSION_STRING, SVN_VERSION); 534 fflush(g_fOut); 530 char mesg[200]; 531 532 sprintf(mesg, "NanoVis %s (build %s)\n", NANOVIS_VERSION_STRING, SVN_VERSION); 533 size_t numBytes; 534 ssize_t numWritten; 535 536 numBytes = strlen(mesg); 537 numWritten = write(g_fdOut, mesg, numBytes); 538 if ((ssize_t)numBytes != numWritten) { 539 ERROR("Short write in version string: %s", strerror(errno)); 540 } 535 541 536 542 g_inBufPtr = new ReadBuffer(g_fdIn, 1<<12); -
trunk/packages/vizservers/pymolproxy/Makefile.in
r4060 r4108 7 7 DEFINES = -DSTANDALONE \ 8 8 -DSVN_VERSION=\"$(SVN_VERSION)\" \ 9 -DSTATSDIR=\"$(STATSDIR)\" 9 -DSTATSDIR=\"$(STATSDIR)\" \ 10 -DLOGDIR=\"$(LOGDIR)\" 10 11 EXTRA_CFLAGS = -Wall 11 12 INCLUDES = $(TCL_INC_SPEC) -I$(srcdir) … … 29 30 SVN_VERSION = $(shell svnversion $(srcdir)) 30 31 STATSDIR = @STATSDIR@ 32 LOGDIR = @LOGDIR@ 31 33 32 34 .PHONY: all install clean distclean -
trunk/packages/vizservers/pymolproxy/pymolproxy2.c
r3411 r4108 91 91 92 92 static int debug = FALSE; 93 static char stderrFile[200];94 static FILE *fdebug;95 93 static FILE *frecord; 96 94 static int recording = FALSE; … … 115 113 116 114 #define IO_TIMEOUT (30000) 115 #define CLIENT_READ (3) 116 #define CLIENT_WRITE (4) 117 118 #ifndef LOGDIR 119 #define LOGDIR "/tmp" 120 #endif /* LOGDIR */ 117 121 118 122 #define CVT2SECS(x) ((double)(x).tv_sec) + ((double)(x).tv_usec * 1.0e-6) … … 226 230 227 231 format = TCL_VARARGS_START(const char *, arg1, args); 228 fprintf( fdebug, "pymolproxy: ");229 vfprintf( fdebug, format, args);230 fprintf( fdebug, "\n");231 fflush( fdebug);232 fprintf(stderr, "pymolproxy: "); 233 vfprintf(stderr, format, args); 234 fprintf(stderr, "\n"); 235 fflush(stderr); 232 236 } 233 237 #endif … … 2097 2101 2098 2102 static int 2099 InitProxy(PymolProxy *p, c onst char *fileName, char *const *argv)2103 InitProxy(PymolProxy *p, char *const *argv) 2100 2104 { 2101 2105 int sin[2], sout[2]; /* Pipes to connect to server. */ … … 2127 2131 if (child == 0) { /* Child process */ 2128 2132 int f; 2133 char tmpname[200]; 2129 2134 2130 2135 /* … … 2139 2144 dup2(sin[0], 0); /* Server standard input */ 2140 2145 dup2(sout[1], 1); /* Server standard output */ 2141 f = open(fileName, O_WRONLY | O_CREAT | O_TRUNC, 0600); 2146 2147 /* Redirect child's stdout to a log file. */ 2148 sprintf(tmpname, "%s/PYMOL-%d-stderr.XXXXXX", LOGDIR, getpid()); 2149 f = mkstemp(tmpname); 2142 2150 if (f < 0) { 2143 ERROR("can't open server error file `%s': %s", fileName,2151 ERROR("can't open file `%s' to capture pymol stderr: %s", tmpname, 2144 2152 strerror(errno)); 2145 2153 exit(1); 2146 2154 } 2147 dup2(f, 2); /* Redirect stderr to a file */2155 dup2(f, 2); /* Redirect stderr to a log file */ 2148 2156 2149 2157 /* Close all other descriptors */ … … 2176 2184 p->frame = 1; 2177 2185 p->pid = child; 2178 InitReadBuffer(&p->client, "client", p->cout, 1<<16);2186 InitReadBuffer(&p->client, "client", CLIENT_READ, 1<<16); 2179 2187 InitReadBuffer(&p->server, "server", p->sout, 1<<18); 2180 2188 … … 2256 2264 result = WEXITSTATUS(result); 2257 2265 } 2258 unlink(stderrFile);2259 2266 return result; 2260 2267 } … … 2299 2306 #endif 2300 2307 break; /* This was caused by a "imgflush" 2301 * command. Break out of the read loop2302 * and allow a new image to be2308 * command. Break out of the read 2309 * loop and allow a new image to be 2303 2310 * rendered. */ 2304 2311 } … … 2311 2318 } 2312 2319 tv.tv_sec = 0L; 2313 tv.tv_usec = 0L; /* On successive reads, we break 2314 * out * if no data is 2315 * available. */ 2320 tv.tv_usec = 0L; /* On successive reads, we break 2321 * out if no data is available. */ 2316 2322 tvPtr = &tv; 2317 2323 } … … 2405 2411 struct timeval tv; 2406 2412 fd_set writeFds; 2407 int fd;2408 2413 2409 2414 tv.tv_sec = tv.tv_usec = 0L; 2410 2415 FD_ZERO(&writeFds); 2411 fd = fileno(stdout); 2412 FD_SET(fd, &writeFds); 2413 if (select(fd+1, NULL, &writeFds, NULL, &tv) > 0) { 2414 WriteImages(&list, fd); 2416 FD_SET(CLIENT_WRITE, &writeFds); 2417 if (select(CLIENT_WRITE+1, NULL, &writeFds, NULL, &tv) > 0) { 2418 WriteImages(&list, CLIENT_WRITE); 2415 2419 } 2416 2420 } … … 2428 2432 PymolProxy proxy; 2429 2433 pthread_t thread1, thread2; 2430 2431 sprintf(stderrFile, "/tmp/pymol%d.stderr", getpid()); 2432 fdebug = stderr; 2433 if (debug) { 2434 fdebug = fopen("/tmp/pymolproxy.log", "w"); 2435 } 2434 char version[200]; 2435 ssize_t numWritten; 2436 size_t numBytes; 2437 2436 2438 frecord = NULL; 2437 2439 if (recording) { … … 2441 2443 frecord = fopen(fileName, "w"); 2442 2444 } 2443 fprintf(stdout, "PyMol 1.0 (build %s)\n", SVN_VERSION); 2444 fflush(stdout); 2445 2445 sprintf(version, "PyMol 1.0 (build %s)\n", SVN_VERSION); 2446 numBytes = strlen(version); 2447 numWritten = write(CLIENT_WRITE, version, numBytes); 2448 if (numWritten < numBytes) { 2449 ERROR("Short write on version string", strerror(errno)); 2450 } 2446 2451 INFO("Starting pymolproxy (threaded version)"); 2447 2452 2448 InitProxy(&proxy, stderrFile,argv + 1);2453 InitProxy(&proxy, argv + 1); 2449 2454 if (pthread_create(&thread1, NULL, &ClientToServer, &proxy) < 0) { 2450 2455 ERROR("Can't create reader thread: %s", strerror(errno)); -
trunk/packages/vizservers/vtkvis/RenderServer.cpp
r4107 r4108 43 43 44 44 int VtkVis::g_statsFile = -1; ///< Stats output file descriptor. 45 int VtkVis::g_fdIn = STDIN_FILENO; ///< Input file descriptor 46 int VtkVis::g_fdOut = STDOUT_FILENO; ///< Output file descriptor 45 #define CLIENT_READ (3) 46 #define CLIENT_WRITE (4) 47 int VtkVis::g_fdIn = CLIENT_READ; ///< Input file descriptor 48 int VtkVis::g_fdOut = CLIENT_WRITE; ///< Output file descriptor 47 49 FILE *VtkVis::g_fOut = NULL; ///< Output file handle 48 50 FILE *VtkVis::g_fLog = NULL; ///< Trace logging file handle … … 407 409 initService() 408 410 { 411 // Create a stream associated with the client read file descriptor. If 412 // we're not using a socket (fdopen of descriptor 4 will return NULL), 413 // then use descriptor 1 and stdout respectively. 409 414 g_fOut = fdopen(g_fdOut, "w"); 410 415 // If running without socket, use stdout for debugging 411 416 if (g_fOut == NULL && g_fdOut != STDOUT_FILENO) { 412 417 g_fdOut = STDOUT_FILENO; 413 g_fOut = fdopen(g_fdOut, "w");418 g_fOut = stdout; 414 419 } 415 420 … … 431 436 } 432 437 438 // Nanoscale automatically redirects stdout and stderr to log files. 433 439 // open log and map stderr to log file 434 440 g_fLog = fopen(logName, "w"); 435 441 dup2(fileno(g_fLog), STDERR_FILENO); 436 // If we are writing to socket, map stdout to log437 if (g_fdOut != STDOUT_FILENO) {438 dup2(fileno(g_fLog), STDOUT_FILENO);439 }440 441 fflush(stdout);442 442 443 443 // clean up malloc'd memory -
trunk/packages/vizservers/vtkvis/RendererCmd.cpp
r4092 r4108 12920 12920 * available. */ 12921 12921 while (inBufPtr->isLineAvailable() || 12922 (select( 1, &readFds, NULL, NULL, tvPtr) > 0)) {12922 (select(inBufPtr->file()+1, &readFds, NULL, NULL, tvPtr) > 0)) { 12923 12923 size_t numBytes; 12924 12924 unsigned char *buffer;
Note: See TracChangeset
for help on using the changeset viewer.