Changeset 6568
- Timestamp:
- Nov 3, 2016 10:57:57 PM (7 years ago)
- Location:
- vtkvis/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
vtkvis/trunk/RenderServer.cpp
r6383 r6568 482 482 signal(SIGPIPE, SIG_IGN); 483 483 484 long idleTimeout = -1L; 484 485 while (1) { 485 int c = getopt(argc, argv, "i:o: ");486 int c = getopt(argc, argv, "i:o:t:"); 486 487 if (c == -1) { 487 488 break; … … 502 503 } 503 504 break; 505 case 't': 506 // Idle timeout in seconds 507 idleTimeout = atol(optarg); 508 break; 504 509 case '?': 505 510 break; … … 543 548 g_inBufPtr = new ReadBuffer(g_fdIn, 1<<12); 544 549 550 g_renderer->setIdleTimeout(idleTimeout); 551 545 552 Tcl_Interp *interp = Tcl_CreateInterp(); 546 553 ClientData clientData = NULL; … … 563 570 // Start main server loop 564 571 for (;;) { 565 if (processCommands(interp, clientData, g_inBufPtr, g_fdOut) < 0) 572 struct timeval timeout; 573 g_renderer->getTimeout(&timeout); 574 int cmdStatus = processCommands(interp, clientData, g_inBufPtr, g_fdOut, &timeout); 575 if (cmdStatus < 0) 566 576 break; 567 577 … … 577 587 g_stats.nFrameBytes += imgData->GetDataSize() * imgData->GetDataTypeSize(); 578 588 } else { 579 TRACE("No render required"); 580 sendAck(clientData, g_fdOut); 589 if (cmdStatus > 1) { 590 sendAck(clientData, g_fdOut); 591 } else { 592 TRACE("No render required and status = %d", cmdStatus); 593 } 581 594 } 582 595 -
vtkvis/trunk/Renderer.cpp
r6554 r6568 76 76 _needsCameraClippingRangeReset(false), 77 77 _needsCameraReset(false), 78 _idleTimeout(-1L), 78 79 _windowWidth(500), 79 80 _windowHeight(500), … … 4646 4647 4647 4648 /** 4649 * \brief Get a timeout for select() 4650 * 4651 * For now, this just returns the idle timeout, if set. 4652 * 4653 * Potentially, this could be used to set a timeout based on the "unused" frame 4654 * time from the previous render based on a target frame rate (and polling if 4655 * we broke frame). 4656 */ 4657 void Renderer::getTimeout(struct timeval *tv) 4658 { 4659 tv->tv_sec = _idleTimeout; 4660 tv->tv_usec = 0L; 4661 } 4662 4663 /** 4648 4664 * \brief Cause the rendering to render a new image if needed 4649 4665 * -
vtkvis/trunk/Renderer.h
r4814 r6568 984 984 void setWarpWarpScale(const DataSetId& id, double scale); 985 985 986 void setIdleTimeout(long timeout) 987 { 988 TRACE("Setting idle timeout to %ld sec", timeout); 989 _idleTimeout = timeout; 990 } 991 992 long getIdleTimeout() 993 { 994 return _idleTimeout; 995 } 996 997 void getTimeout(struct timeval *tv); 998 986 999 private: 987 1000 typedef std::tr1::unordered_map<DataSetId, DataSet *> DataSetHashmap; … … 1086 1099 bool _needsCameraClippingRangeReset; 1087 1100 bool _needsCameraReset; 1101 1102 long _idleTimeout; 1088 1103 1089 1104 int _windowWidth, _windowHeight; -
vtkvis/trunk/RendererCmd.cpp
r6384 r6568 13070 13070 ClientData clientData, 13071 13071 ReadBuffer *inBufPtr, 13072 int fdOut) 13072 int fdOut, 13073 struct timeval *timeout) 13073 13074 { 13074 13075 int ret = 1; … … 13082 13083 FD_ZERO(&readFds); 13083 13084 FD_SET(inBufPtr->file(), &readFds); 13084 tvPtr = NULL; /* Wait for the first read. This is so 13085 * that we don't spin when no data is 13086 * available. */ 13087 while (inBufPtr->isLineAvailable() || 13088 (select(inBufPtr->file()+1, &readFds, NULL, NULL, tvPtr) > 0)) { 13085 13086 bool polling = false; 13087 if (timeout->tv_sec >= 0L) { 13088 tv.tv_sec = timeout->tv_sec; 13089 tv.tv_usec = timeout->tv_usec; 13090 polling = tv.tv_sec == 0 && tv.tv_usec == 0; 13091 tvPtr = &tv; 13092 } else { 13093 // Block until data available 13094 tvPtr = NULL; 13095 TRACE("Blocking on select()"); 13096 } 13097 while (inBufPtr->isLineAvailable() || 13098 ((ret = select(inBufPtr->file()+1, &readFds, NULL, NULL, tvPtr)) > 0)) { 13089 13099 size_t numBytes; 13090 13100 unsigned char *buffer; … … 13123 13133 } 13124 13134 } 13135 if (status == TCL_OK) { 13136 ret = 3; 13137 } 13125 13138 } 13126 13139 13140 polling = true; 13127 13141 tv.tv_sec = tv.tv_usec = 0L; /* On successive reads, we break out 13128 13142 * if no data is available. */ 13129 13143 FD_SET(inBufPtr->file(), &readFds); 13130 13144 tvPtr = &tv; 13145 } 13146 if (!polling && ret == 0 && timeout->tv_sec > 0L) { 13147 // If idle timeout expired, disconnect 13148 TRACE("Exiting server after timeout waiting for client command"); 13149 return -1; 13131 13150 } 13132 13151 -
vtkvis/trunk/RendererCmd.h
r3621 r6568 9 9 #define VTKVIS_RENDERERCMD_H 10 10 11 #include <sys/time.h> 11 12 #include <cstdio> 12 13 #include <tcl.h> … … 28 29 ClientData clientData, 29 30 ReadBuffer *inBufPtr, 30 int fdOut); 31 int fdOut, 32 struct timeval *timeout); 31 33 32 34 extern int handleError(Tcl_Interp *interp,
Note: See TracChangeset
for help on using the changeset viewer.