- Timestamp:
- Sep 21, 2011, 7:06:23 PM (13 years ago)
- Location:
- branches/vtkvis_threaded
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/vtkvis_threaded/Makefile.in
r2523 r2551 84 84 ColorMap.cpp \ 85 85 PPMWriter.cpp \ 86 ReadBuffer.cpp \ 86 87 RpContour2D.cpp \ 87 88 RpContour3D.cpp \ -
branches/vtkvis_threaded/RpVtkRenderServer.cpp
r2498 r2551 22 22 23 23 #include "Trace.h" 24 #include "ReadBuffer.h" 24 25 #include "RpVtkRenderServer.h" 25 26 #include "RpVtkRendererCmd.h" … … 40 41 FILE *Rappture::VtkVis::g_fLog = NULL; ///< Trace logging file handle 41 42 Renderer *Rappture::VtkVis::g_renderer = NULL; ///< Main render worker 43 ReadBuffer *Rappture::VtkVis::g_inBufPtr; 42 44 43 45 #define ELAPSED_TIME(t1, t2) \ … … 247 249 vtkSmartPointer<vtkUnsignedCharArray> imgData = 248 250 vtkSmartPointer<vtkUnsignedCharArray>::New(); 251 ReadBuffer inBuf(fileno(g_fIn), 1<<12); 252 g_inBufPtr = &inBuf; 249 253 for (;;) { 250 254 int ret; 251 255 252 ret = processCommands(interp, g_fIn, g_fOut);256 ret = processCommands(interp, &inBuf, g_fOut); 253 257 if (ret < 0) 254 258 break; … … 260 264 TRACE("No render required"); 261 265 } 262 if ( feof(g_fIn))266 if (inBuf.status() == ReadBuffer::ENDFILE) 263 267 break; 264 268 } … … 340 344 vtkSmartPointer<vtkUnsignedCharArray> imgData = 341 345 vtkSmartPointer<vtkUnsignedCharArray>::New(); 346 ReadBuffer inBuf(fileno(g_fIn), 1<<12); 347 g_inBufPtr = &inBuf; 342 348 while (1) { 343 ret = processCommands(interp, g_fIn, g_fOut);349 ret = processCommands(interp, &inBuf, g_fOut); 344 350 if (ret < 0) 345 351 break; … … 353 359 } 354 360 355 if ( feof(g_fIn))361 if (inBuf.status() == ReadBuffer::ENDFILE) 356 362 break; 357 363 } … … 371 377 return 0; 372 378 } 373 -
branches/vtkvis_threaded/RpVtkRenderServer.h
r2523 r2551 20 20 extern FILE *g_fLog; 21 21 extern Renderer *g_renderer; 22 extern ReadBuffer *g_inBufPtr; 22 23 23 24 } -
branches/vtkvis_threaded/RpVtkRendererCmd.cpp
r2523 r2551 19 19 #include "Trace.h" 20 20 #include "CmdProc.h" 21 #include "ReadBuffer.h" 21 22 #include "RpVtkRendererCmd.h" 22 23 #include "RpVtkRenderServer.h" … … 65 66 #endif /*USE_THREADS*/ 66 67 67 static size_t 68 SocketRead(void *bytes, size_t len) 69 { 70 #ifdef notdef 71 size_t ofs = 0; 72 ssize_t bytesRead = 0; 73 while ((bytesRead = read(g_fdIn, bytes + ofs, len - ofs)) > 0) { 74 ofs += bytesRead; 75 if (ofs == len) 76 break; 77 } 78 TRACE("bytesRead: %lu", ofs); 79 return ofs; 80 #else 81 size_t bytesRead = fread(bytes, 1, len, g_fIn); 82 TRACE("bytesRead: %lu", bytesRead); 83 return bytesRead; 84 #endif 68 static bool 69 SocketRead(char *bytes, size_t len) 70 { 71 ReadBuffer::BufferStatus status; 72 status = g_inBufPtr->FollowingData((unsigned char *)bytes, len); 73 TRACE("bytesRead: %lu", status); 74 return (status == ReadBuffer::OK); 85 75 } 86 76 … … 1688 1678 } 1689 1679 char *data = (char *)malloc(nbytes); 1690 size_t bytesRead = SocketRead(data, nbytes); 1691 if (bytesRead < (size_t)nbytes) { 1680 if (!SocketRead(data, nbytes)) { 1692 1681 free(data); 1693 1682 return TCL_ERROR; … … 4767 4756 } 4768 4757 char *data = (char *)malloc(nbytes); 4769 size_t bytesRead = SocketRead(data, nbytes); 4770 if (bytesRead < (size_t)nbytes) { 4758 if (!SocketRead(data, nbytes)) { 4771 4759 free(data); 4772 4760 return TCL_ERROR; … … 4816 4804 } 4817 4805 char *data = (char *)malloc(nbytes); 4818 size_t bytesRead = SocketRead(data, nbytes); 4819 if (bytesRead < (size_t)nbytes) { 4806 if (!SocketRead(data, nbytes)) { 4820 4807 free(data); 4821 4808 return TCL_ERROR; … … 5364 5351 */ 5365 5352 int 5366 Rappture::VtkVis::processCommands(Tcl_Interp *interp, FILE *fin, FILE *fout) 5353 Rappture::VtkVis::processCommands(Tcl_Interp *interp, ReadBuffer *inBufPtr, 5354 FILE *fout) 5367 5355 { 5368 5356 int status = TCL_OK; 5369 5370 #define BUFFERSIZE ((1<<16)-1)5371 char buffer[BUFFERSIZE+1];5372 5357 5373 5358 Tcl_DString command; 5374 5359 Tcl_DStringInit(&command); 5375 5376 5360 fd_set readFds; 5377 5361 struct timeval tv, *tvPtr; 5378 5362 5379 5363 FD_ZERO(&readFds); 5380 FD_SET( fileno(fin), &readFds);5364 FD_SET(inBufPtr->file(), &readFds); 5381 5365 tvPtr = NULL; /* Initially there is no timeout. */ 5382 while (select(1, &readFds, NULL, NULL, tvPtr) > 0) { 5383 if (fgets(buffer, BUFFERSIZE, fin) == NULL) { 5384 /* Terminate the server if we can't 5385 * communicate with the client 5366 while ((inBufPtr->IsLineAvailable()) || 5367 ((select(1, &readFds, NULL, NULL, tvPtr) > 0))) { 5368 size_t numBytes; 5369 unsigned char *buffer; 5370 5371 if (inBufPtr->GetLine(&numBytes, &buffer) != ReadBuffer::OK) { 5372 /* Terminate the server if we can't communicate with the client 5386 5373 * anymore. */ 5387 if ( feof(fin)) {5374 if (inBufPtr->status() == ReadBuffer::ENDFILE) { 5388 5375 INFO("Exiting server on EOF from client"); 5389 5376 exit(0); … … 5394 5381 } 5395 5382 } 5396 buffer[BUFFERSIZE] = '\0'; 5397 Tcl_DStringAppend(&command, buffer, -1); 5383 Tcl_DStringAppend(&command, (char *)buffer, numBytes); 5398 5384 if (Tcl_CommandComplete(Tcl_DStringValue(&command))) { 5399 5385 status = ExecuteCommand(interp, &command); … … 5406 5392 } 5407 5393 tv.tv_sec = tv.tv_usec = 0L; 5408 FD_SET( fileno(fin), &readFds);5394 FD_SET(inBufPtr->file(), &readFds); 5409 5395 tvPtr = &tv; 5410 5396 } -
branches/vtkvis_threaded/RpVtkRendererCmd.h
r2495 r2551 11 11 #include <cstdio> 12 12 #include <tcl.h> 13 #include "ReadBuffer.h" 13 14 14 15 namespace Rappture { 15 16 namespace VtkVis { 16 17 17 extern int processCommands(Tcl_Interp *interp, FILE *fin, FILE *fout); 18 extern int processCommands(Tcl_Interp *interp, ReadBuffer *inBufPtr, 19 FILE *fout); 18 20 extern void initTcl(Tcl_Interp *interp, ClientData clientData); 19 21 extern void exitTcl(Tcl_Interp *interp);
Note: See TracChangeset
for help on using the changeset viewer.