Changeset 6404 for geovis/trunk
- Timestamp:
- Jun 21, 2016, 12:53:52 AM (8 years ago)
- Location:
- geovis/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
geovis/trunk/RenderServer.cpp
r6386 r6404 232 232 233 233 static void 234 exitService( )234 exitService(int code) 235 235 { 236 236 TRACE("Enter"); 237 237 238 serverStats(g_stats, 0);238 serverStats(g_stats, code); 239 239 240 240 // close log file … … 297 297 std::string resourcePath; 298 298 double maxbitrate = 1.0e8; 299 long idleTimeout = -1L; 299 300 while (1) { 300 int c = getopt(argc, argv, "r:p:i:o: ");301 int c = getopt(argc, argv, "r:p:i:o:t:"); 301 302 if (c == -1) { 302 303 break; … … 323 324 } 324 325 } 326 break; 327 case 't': 328 // Idle timeout in seconds 329 idleTimeout = atol(optarg); 325 330 break; 326 331 case '?': … … 365 370 } 366 371 g_renderer->setResourcePath(resourcePath); 372 g_renderer->setIdleTimeout(idleTimeout); 367 373 368 374 TRACE("Default Tcl encoding dir: %s", Tcl_GetDefaultEncodingDir()); … … 385 391 // Start main server loop 386 392 for (;;) { 387 long timeout = g_renderer->getTimeout(); 393 struct timeval timeout; 394 g_renderer->getTimeout(&timeout); 388 395 #ifdef SLEEP_AFTER_QUEUE_FRAME 389 396 g_renderer->markFrameStart(); 390 397 #endif 391 int cmdStatus = processCommands(interp, NULL, g_inBufPtr, g_fdOut, timeout);398 int cmdStatus = processCommands(interp, NULL, g_inBufPtr, g_fdOut, &timeout); 392 399 if (cmdStatus < 0) 393 400 break; … … 476 483 477 484 closeLog(); 478 exitService( );485 exitService(0); 479 486 480 487 return 0; -
geovis/trunk/Renderer.cpp
r6380 r6404 127 127 _windowWidth(500), 128 128 _windowHeight(500), 129 _idleTimeout(-1L), 129 130 _pickPending(false), 130 131 _scaleBarUnits(UNITS_METERS) … … 2854 2855 2855 2856 /** 2856 * \brief Get a timeout in usecsfor select()2857 * \brief Get a timeout for select() 2857 2858 * 2858 2859 * If the paging thread is idle, returns <0 indicating that the … … 2861 2862 * rate, return the remaining frame time. 2862 2863 */ 2863 long Renderer::getTimeout()2864 { 2865 if (!checkNeedToDoFrame()) 2864 void Renderer::getTimeout(struct timeval *tv) 2865 { 2866 if (!checkNeedToDoFrame()) { 2866 2867 // <0 means no timeout, block until socket has data 2867 return -1L; 2868 if (_lastFrameTime < _minFrameTime) { 2869 return (long)1.0e6*(_minFrameTime - _lastFrameTime); 2868 // If _idleTimeout is positive, server will disconnect after timeout 2869 tv->tv_sec = _idleTimeout; 2870 tv->tv_usec = 0L; 2871 } else if (_lastFrameTime < _minFrameTime) { 2872 tv->tv_sec = 0L; 2873 tv->tv_usec = (long)1.0e6*(_minFrameTime - _lastFrameTime); 2870 2874 } else { 2871 2875 // No timeout (poll) 2872 return0L;2876 tv->tv_sec = tv->tv_usec = 0L; 2873 2877 } 2874 2878 } -
geovis/trunk/Renderer.h
r6380 r6404 9 9 #define GEOVIS_RENDERER_H 10 10 11 #include <sys/time.h> // For struct timeval 11 12 #include <ctime> // For time_t 12 13 #include <string> … … 528 529 void markFrameEnd(); 529 530 530 long getTimeout(); 531 void setIdleTimeout(long timeout) 532 { 533 if (timeout != -1L && 534 (double)timeout < _minFrameTime) { 535 ERROR("Timeout must be more than %g sec", _minFrameTime); 536 return; 537 } 538 TRACE("Setting idle timeout to %ld sec", timeout); 539 _idleTimeout = timeout; 540 } 541 542 long getIdleTimeout() 543 { 544 return _idleTimeout; 545 } 546 547 void getTimeout(struct timeval *tv); 531 548 532 549 void mapNodeUpdate(); … … 642 659 float _bgColor[3]; 643 660 661 long _idleTimeout; 644 662 double _minFrameTime; 645 663 double _lastFrameTime; -
geovis/trunk/RendererCmd.cpp
r6387 r6404 17 17 #include <unistd.h> 18 18 #include <sys/select.h> 19 #include <sys/time.h> 19 20 #include <sys/uio.h> 20 21 #include <tcl.h> … … 96 97 ReadBuffer::BufferStatus status; 97 98 status = g_inBufPtr->followingData((unsigned char *)bytes, len); 99 g_stats.nDataBytes += len; 98 100 TRACE("followingData status: %d", status); 99 101 return (status == ReadBuffer::OK); … … 2421 2423 } 2422 2424 g_renderer->addModelLayer(name, geomOpts, pos, cache, lighting, visible); 2423 } else if (type[0] == 't' && strcmp(type, "text") == 0) {2425 } else if (type[0] == 't' && strcmp(type, "text") == 0) { 2424 2426 char *driver = Tcl_GetString(objv[5]); 2425 2427 char *format = Tcl_GetString(objv[6]); … … 3766 3768 ReadBuffer *inBufPtr, 3767 3769 int fdOut, 3768 longtimeout)3770 struct timeval *timeout) 3769 3771 { 3770 3772 int ret = 1; … … 3778 3780 FD_ZERO(&readFds); 3779 3781 FD_SET(inBufPtr->file(), &readFds); 3780 tvPtr = NULL; /* Wait for the first read. This is so 3781 * that we don't spin when no data is 3782 * available. */ 3783 if (timeout >= 0L) { 3784 tv.tv_sec = 0L; 3785 tv.tv_usec = timeout; 3782 3783 bool polling = false; 3784 if (timeout->tv_sec >= 0L) { 3785 tv.tv_sec = timeout->tv_sec; 3786 tv.tv_usec = timeout->tv_usec; 3786 3787 tvPtr = &tv; 3787 3788 } else { 3789 // Block until data available 3790 tvPtr = NULL; 3788 3791 TRACE("Blocking on select()"); 3789 3792 } … … 3842 3845 } 3843 3846 3847 polling = true; 3844 3848 tv.tv_sec = tv.tv_usec = 0L; /* On successive reads, we break out 3845 3849 * if no data is available. */ 3846 3850 FD_SET(inBufPtr->file(), &readFds); 3847 3851 tvPtr = &tv; 3852 } 3853 if (!polling && ret == 0 && timeout->tv_sec > 0L) { 3854 // If idle timeout expired, disconnect 3855 TRACE("Exiting server after timeout waiting for client command"); 3856 return -1; 3848 3857 } 3849 3858 -
geovis/trunk/RendererCmd.h
r4028 r6404 9 9 #define GEOVIS_RENDERERCMD_H 10 10 11 #include <sys/time.h> 11 12 #include <cstdio> 12 13 #include <tcl.h> … … 31 32 ReadBuffer *inBufPtr, 32 33 int fdOut, 33 long timeout = -1);34 struct timeval *timeout); 34 35 35 36 extern int handleError(Tcl_Interp *interp,
Note: See TracChangeset
for help on using the changeset viewer.