Changeset 25455 for gs2-extensions
- Timestamp:
- 2012-04-23T11:00:25+12:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/tdb-edit/trunk/src/bin/script/TDBServer.pl
r25454 r25455 77 77 # Globally available - but once set these are read-only - so locking isn't 78 78 # an issue 79 my $use_harness = 0;79 my $use_harness = 1; 80 80 my $tdbexe = 'tdbcli'; 81 81 my $parent_pid = 0; … … 430 430 my $record = '[' . $key . ']' . $action . $payload; 431 431 # Open harness to TDBCLI 432 &debugPrint($the_count, $tid, 'TDBCLI', 'Opening harness'); 432 433 my @tdb_command = ($tdbexe, $tdb_path, '-mid ' . $the_count); 433 434 my $buffer_to_tdb = ''; … … 441 442 # - write the data to the TDBCLI 442 443 $buffer_to_tdb = $record . "\n"; 443 my $write_msg = '#' . $the_count . ' writing: |' . $record . '| => ';444 444 while (length($buffer_to_tdb)) 445 445 { 446 $write_msg .='.';447 446 pump($tdb_harness); 448 447 } 449 print STDERR $write_msg . "\n";450 448 # - read any response from TDBCLI 451 my $read_msg = '#' . $the_count . ' reading: ';449 &debugPrint($the_count, $tid, 'TDBCLI', 'Reading'); 452 450 while ($buffer_from_tdb !~ /-{70}/) 453 451 { 454 $read_msg .= '.';455 452 pump($tdb_harness); 456 453 } 457 print STDERR $read_msg . ' => |' . $buffer_from_tdb . "|\n"; 454 # - explicitly tell the pipe to quit (empty key) 455 &debugPrint($the_count, $tid, 'TDBCLI', 'Closing'); 456 $buffer_to_tdb = "[]\n"; 457 while (length($buffer_to_tdb)) 458 { 459 pump($tdb_harness); 460 } 458 461 # - not that this result doesn't include the [Server] prefix as it 459 462 # may be parsed for data by the client … … 461 464 chomp($result); 462 465 # Finished with harness 466 &debugPrint($the_count, $tid, 'TDBCLI', 'Finishing harness'); 463 467 finish($tdb_harness); 468 &debugPrint($the_count, $tid, 'TDBCLI', 'Complete'); 464 469 } 465 470 # Use different TDB tools depending on arguments … … 467 472 elsif ($action eq '?') 468 473 { 469 my $command = 'tdbget "' . $tdb_path . '" "' . $key . '"';470 &debugPrint($the_count, $tid, 'TDBGET', 'Command: ' . $command );471 my $result = `$command `;474 my $command1 = 'tdbget "' . $tdb_path . '" "' . $key . '"'; 475 &debugPrint($the_count, $tid, 'TDBGET', 'Command: ' . $command1); 476 my $result = `$command1`; 472 477 &debugPrint($the_count, $tid, 'TDBGET', 'Result: ' . $result); 473 478 if ($result =~ /-{70}/) … … 479 484 elsif ($action eq '+' || $action eq '-') 480 485 { 481 my $command = 'txt2tdb "' . $tdb_path . '" -append';482 &debugPrint($the_count, $tid, 'TXT2TDB', 'Command: ' . $command );483 open(my $infodb_handle, '| ' . $command ) or die("Error! Failed to open pipe to TXT2TDB\n");486 my $command2 = 'txt2tdb "' . $tdb_path . '" -append'; 487 &debugPrint($the_count, $tid, 'TXT2TDB', 'Command: ' . $command2); 488 open(my $infodb_handle, '| ' . $command2) or die("Error! Failed to open pipe to TXT2TDB\n"); 484 489 print $infodb_handle '[' . $key . ']'; 485 490 if ($action eq '-')
Note:
See TracChangeset
for help on using the changeset viewer.