Changeset 6835


Ignore:
Timestamp:
10/13/16 10:54:17 (3 years ago)
Author:
scott
Message:

Added -t flag to cause module to self-terminate after specified number of seconds

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/release_notes.working

    r6834 r6835  
    7777Scott Hunter    December 3, 2015 
    7878 
     79sniffrings 
     80Added option for it to self-terminate after a specified number of seconds. 
     81Scott Hunter    October 13, 2016 
     82 
    7983 
    8084CHANGES TO CONFIGURATION FILES and DESCRIPTOR FILES: 
  • trunk/src/diagnostic_tools/sniffrings/sniffrings.c

    r6803 r6835  
    3737#include <mem_circ_queue.h>  
    3838 
     39#define VERSION  "1.0.1 2016.10.10" 
     40 
    3941#define MAX_SIZE MAX_BYTES_PER_EQ   /* Largest message size in characters */ 
    4042 
     
    136138  int          wait_time_thr_count = 0;       /* counter of waiting time for joining all threads */ 
    137139 
     140  time_t       expiration_date = 0;           /* if non-0, self terminate after this time */ 
     141   
    138142  cmdname = argv[0]; 
    139143 
     
    145149  /* Check program arguments 
    146150   ***********************/ 
    147   if ( (argc < 2) || (argc > 7) ) 
    148   { 
    149     printf( "Usage 1:  sniffrings [-n] <ringnames>\n" ); 
    150     printf( "Usage 2:  sniffrings [-n] <ringnames> <instid> <mod> <type>\n" ); 
    151     printf( "Usage 3:  sniffrings [-n] <ringnames> verbose \n" ); 
    152     printf( "Usage 4:  sniffrings [-n] <ringnames> <instid> <mod> <type> verbose\n" ); 
     151  if ( (argc < 2) || (argc > 9) ) 
     152  { 
     153    printf( "Version %s\n", VERSION ); 
     154    printf( "Usage 1:  sniffrings [-n] <ringnames> [-t secs]\n" ); 
     155    printf( "Usage 2:  sniffrings [-n] <ringnames> <instid> <mod> <type> [-t secs]\n" ); 
     156    printf( "Usage 3:  sniffrings [-n] <ringnames> verbose  [-t secs]\n" ); 
     157    printf( "Usage 4:  sniffrings [-n] <ringnames> <instid> <mod> <type> verbose [-t secs]\n" ); 
    153158    printf( "<ringnames> is in the form of comma-separated-values. (i.e. PICK_RING,HYPO_RING).\n" ); 
    154159    printf( "Sniffring shows full ring, inst and module names if 'v' or \n" ); 
     
    158163    printf( "A new option is -n to not flush the ring of all messages first, must be before ringname if used\n" ); 
    159164    printf( "the default is to flush the ring of all messages and only show those that come in after invocation\n" ); 
     165    printf( "-t secs specifies that sniffrings self-terminates after the specified number of seconds\n" ); 
    160166    return -1; 
    161167  } 
     
    173179    return -1; 
    174180  } 
     181   
     182  if ( argc >= 4 && strcmp(argv[argc-2],"-t") == 0 ) { 
     183    int seconds = atoi( argv[argc-1] ); 
     184    if ( seconds <= 0 ) { 
     185        printf( "sniffrings: argument to -t must be a positive integer; exiting!\n" ); 
     186        return -1; 
     187    } 
     188    expiration_date = seconds;    /* so we know to set a real time once the actual processing starts */ 
     189    argc -= 2; 
     190  } 
     191     
    175192 
    176193  remove_duplicated_ringname(InRings, &nRings); 
     
    315332  } 
    316333 
     334  /* If self-termination requested, set the time to do so 
     335   ******************************************************/ 
     336  if ( expiration_date > 0 ) { 
     337     time(&now); 
     338     expiration_date += now; 
     339  } 
     340   
    317341  /* Start main sniffrings service loop, which aimlessly beats its heart. 
    318342   **********************************/ 
     
    330354       } 
    331355       */ 
     356     
     357    /* Check for self-termination  
     358     *****************************/ 
     359    if ( expiration_date && (now > expiration_date) ) { 
     360        printf("%s: self-termination requested.\n", cmdname); 
     361        break; 
     362    } 
    332363 
    333364    /* take a brief nap 
     
    459490        case GET_NOTRACK: 
    460491          time(&now); 
    461           snprintf( errText, STR_LEN_ERRTEXT-1, "%ld %hd no tracking for logo i%d m%d t%d in %s", 
     492          snprintf( errText, STR_LEN_ERRTEXT-1, "%ld %d no tracking for logo i%d m%d t%d in %s", 
    462493              (long)now, ERR_NOTRACK, (int) reclogo.instid, (int) reclogo.mod, 
    463494              (int)reclogo.type, args_stacker->InRing ); 
     
    466497        case GET_MISS_LAPPED: 
    467498          time(&now); 
    468           snprintf( errText, STR_LEN_ERRTEXT-1, "%ld %hd msg(s) overwritten i%d m%d t%d in %s", 
     499          snprintf( errText, STR_LEN_ERRTEXT-1, "%ld %d msg(s) overwritten i%d m%d t%d in %s", 
    469500              (long)now, ERR_MISSMSG, (int) reclogo.instid, 
    470501              (int) reclogo.mod, (int)reclogo.type, args_stacker->InRing ); 
     
    473504        case GET_MISS_SEQGAP: 
    474505          time(&now); 
    475           snprintf( errText, STR_LEN_ERRTEXT-1, "%ld %hd gap in msg sequence i%d m%d t%d in %s", 
     506          snprintf( errText, STR_LEN_ERRTEXT-1, "%ld %d gap in msg sequence i%d m%d t%d in %s", 
    476507              (long)now, ERR_MISSMSG, (int) reclogo.instid, 
    477508              (int) reclogo.mod, (int)reclogo.type, args_stacker->InRing ); 
     
    489520        case GET_TOOBIG: 
    490521          time(&now); 
    491           snprintf( errText, STR_LEN_ERRTEXT-1, "%ld %hd msg[%ld] i%d m%d t%d too long for target", 
     522          snprintf( errText, STR_LEN_ERRTEXT-1, "%ld %d msg[%ld] i%d m%d t%d too long for target", 
    492523              (long)now, ERR_TOOBIG, recsize, (int) reclogo.instid, 
    493524              (int) reclogo.mod, (int)reclogo.type ); 
     
    514545          /* Currently, enqeueue() in mem_circ_queue.c never returns this error. */ 
    515546          time(&now); 
    516           snprintf(errText, STR_LEN_ERRTEXT-1,"%ld %hd internal queue error. Terminating.", (long)now, ERR_QUEUE); 
     547          snprintf(errText, STR_LEN_ERRTEXT-1,"%ld %d internal queue error. Terminating.", (long)now, ERR_QUEUE); 
    517548          printf("%s\n", errText); 
    518549          error_occurred = 1; 
     
    520551        case -1: 
    521552          time(&now); 
    522           snprintf(errText, STR_LEN_ERRTEXT-1,"%ld %hd message too big for queue.", (long)now, 
     553          snprintf(errText, STR_LEN_ERRTEXT-1,"%ld %d message too big for queue.", (long)now, 
    523554              ERR_QUEUE); 
    524555          printf("%s\n", errText); 
Note: See TracChangeset for help on using the changeset viewer.