Ignore:
Timestamp:
2012-04-26T10:24:32+12:00 (12 years ago)
Author:
jmt12
Message:

Debugged non-harness mode and fixed a few issues (for instance, needing to call TDBKEYS when * is given as the target key)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs2-extensions/tdb-edit/trunk/src/bin/script/TDBServer.pl

    r25455 r25477  
    7777# Globally available - but once set these are read-only - so locking isn't
    7878# an issue
    79 my $use_harness = 1;
     79my $use_harness = 0;
    8080my $tdbexe = 'tdbcli';
    8181my $parent_pid = 0;
     
    404404  # form  <database>:<key>:<value>
    405405  # where: database is [d]oc, [i]ndex, or [s]rc
    406   elsif ($data =~ /^([dis]):\[([^\]]+)\]([+?\-])(.+)$/s)
     406  elsif ($data =~ /^([dis]):\[(.+?)\]([\+\?\-]?)(.*)$/s)
    407407  {
    408408    my $database = $1;
    409409    my $key = $2;
    410     my $action = $3
     410    my $action = $3;
     411    # by default we add for backwards compatibility
     412    if (!defined $action || $action eq '')
     413    {
     414      #rint STDERR "Warning! Detected request without action (#" . $the_count . ") - assuming add/update.\n";
     415      $action = '+';
     416    }
    411417    my $payload = $4;
     418    $payload =~ s/^\s+|\s+$//g;
     419    &debugPrint($the_count, $tid, 'PARSED', 'database=' . $database . ', key=' . $key . ', action=' . $action . ', payload=' . $payload);
    412420    # Build path to database file
    413421    my $tdb_path = '';
     
    472480    elsif ($action eq '?')
    473481    {
    474       my $command1 = 'tdbget "' . $tdb_path . '" "' . $key . '"';
    475       &debugPrint($the_count, $tid, 'TDBGET', 'Command: ' . $command1);
    476       my $result = `$command1`;
    477       &debugPrint($the_count, $tid, 'TDBGET', 'Result: ' . $result);
     482      my $command_name = '';
     483      my $command1 = '';
     484      # Special case for retrieve all keys (indicated by *)
     485      if ($key eq '*')
     486      {
     487        $command_name = 'TDBKEYS';
     488        $command1 = 'tdbkeys "' . $tdb_path . '"';
     489      }
     490      else
     491      {
     492        $command_name = 'TDBGET';
     493        $command1 = 'tdbget "' . $tdb_path . '" "' . $key . '"';
     494      }
     495      &debugPrint($the_count, $tid, $command_name, 'Command: ' . $command1);
     496      $result = `$command1`;
     497      &debugPrint($the_count, $tid, $command_name, 'Result: ' . $result);
    478498      if ($result =~ /-{70}/)
    479499      {
     
    484504    elsif ($action eq '+' || $action eq '-')
    485505    {
    486       my $command2 = 'txt2tdb "' . $tdb_path . '" -append';
     506      my $command2 = 'txt2tdb -append "' . $tdb_path . '"';
    487507      &debugPrint($the_count, $tid, 'TXT2TDB', 'Command: ' . $command2);
    488508      open(my $infodb_handle, '| ' . $command2) or die("Error! Failed to open pipe to TXT2TDB\n");
     
    499519    else
    500520    {
    501       die("Error! Unknown action: " . $action . "\n");
     521      print STDERR "Warning! Request " . $the_count . " asked for unknown action '" . $action . "' - Ignoring!\n";
    502522    }
    503523  }
Note: See TracChangeset for help on using the changeset viewer.