Changeset 6619
- Timestamp:
- Nov 14, 2016 11:35:41 AM (7 years ago)
- Location:
- nanovis/branches/1.2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
nanovis/branches/1.2
- Property svn:mergeinfo changed
/nanovis/trunk merged: 6576-6577
- Property svn:mergeinfo changed
-
nanovis/branches/1.2/Command.cpp
r6392 r6619 2340 2340 int 2341 2341 nv::processCommands(Tcl_Interp *interp, 2342 ReadBuffer *inBufPtr, int fdOut) 2342 ReadBuffer *inBufPtr, 2343 int fdOut, 2344 struct timeval *timeout) 2343 2345 { 2344 2346 int ret = 1; … … 2352 2354 FD_ZERO(&readFds); 2353 2355 FD_SET(inBufPtr->file(), &readFds); 2354 tvPtr = NULL; /* Wait for the first read. This is so 2355 * that we don't spin when no data is 2356 * available. */ 2356 2357 bool polling = false; 2358 if (timeout->tv_sec >= 0L) { 2359 tv.tv_sec = timeout->tv_sec; 2360 tv.tv_usec = timeout->tv_usec; 2361 polling = tv.tv_sec == 0 && tv.tv_usec == 0; 2362 tvPtr = &tv; 2363 } else { 2364 // Block until data available 2365 tvPtr = NULL; 2366 TRACE("Blocking on select()"); 2367 } 2357 2368 while (inBufPtr->isLineAvailable() || 2358 ( select(inBufPtr->file()+1, &readFds, NULL, NULL, tvPtr) > 0)) {2369 ((ret = select(inBufPtr->file()+1, &readFds, NULL, NULL, tvPtr)) > 0)) { 2359 2370 size_t numBytes; 2360 2371 unsigned char *buffer; … … 2393 2404 } 2394 2405 } 2395 } 2396 2406 if (status == TCL_OK) { 2407 ret = 3; 2408 } 2409 } 2410 2411 polling = true; 2397 2412 tv.tv_sec = tv.tv_usec = 0L; /* On successive reads, we break out 2398 2413 * if no data is available. */ 2399 2414 FD_SET(inBufPtr->file(), &readFds); 2400 2415 tvPtr = &tv; 2416 } 2417 if (!polling && ret == 0 && timeout->tv_sec > 0L) { 2418 // If idle timeout expired, disconnect 2419 TRACE("Exiting server after timeout waiting for client command"); 2420 return -1; 2401 2421 } 2402 2422 -
nanovis/branches/1.2/Command.h
r5603 r6619 13 13 14 14 #include <unistd.h> 15 #include <sys/time.h> 15 16 16 17 #include <tcl.h> … … 44 45 extern int processCommands(Tcl_Interp *interp, 45 46 ReadBuffer *inBufPtr, 46 int fdOut); 47 int fdOut, 48 struct timeval *timeout); 47 49 48 50 extern int handleError(Tcl_Interp *interp, -
nanovis/branches/1.2/nanovisServer.cpp
r6395 r6619 57 57 ResponseQueue *nv::g_queue = NULL; 58 58 #endif 59 long nv::g_idleTimeout = -1L; 59 60 60 61 #ifdef USE_THREADS … … 385 386 386 387 #if defined(USE_NEW_EVENT_LOOP) || defined(USE_THREADS) 387 if (processCommands(NanoVis::interp, g_inBufPtr, g_fdOut) < 0) { 388 struct timeval timeout; 389 timeout.tv_sec = g_idleTimeout; 390 timeout.tv_usec = 0L; 391 if (processCommands(NanoVis::interp, g_inBufPtr, g_fdOut, &timeout) < 0) { 388 392 exitService(1); 389 393 } … … 477 481 const char *resourcePath = NULL; 478 482 while (1) { 479 static struct option long_options[] = { 480 {"debug", no_argument, NULL, 'd'}, 481 {"path", required_argument, NULL, 'p'}, 482 {0, 0, 0, 0} 483 }; 484 int option_index = 0; 485 int c = getopt_long(argc, argv, "dp:i:o:", long_options, &option_index); 483 int c = getopt(argc, argv, "dp:i:o:t:"); 486 484 if (c == -1) { 487 485 break; … … 507 505 } 508 506 } 507 break; 508 case 't': 509 // Idle timeout in seconds 510 g_idleTimeout = atol(optarg); 509 511 break; 510 512 case '?': -
nanovis/branches/1.2/nanovisServer.h
r6393 r6619 50 50 extern ResponseQueue *g_queue; 51 51 #endif 52 extern long g_idleTimeout; 52 53 53 54 #ifdef KEEPSTATS
Note: See TracChangeset
for help on using the changeset viewer.