Bug 6140 - Set a timeout to z3950 servers that could have network problems occasionally
Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
This commit is contained in:
parent
843aabf5c1
commit
21b3f8a7bf
|
|
@ -40,7 +40,7 @@ sub StringSearch {
|
|||
$searchstring = '';
|
||||
}
|
||||
|
||||
my $query = "SELECT host,port,db,userid,password,name,id,checked,rank,syntax,encoding";
|
||||
my $query = "SELECT host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout";
|
||||
$query .= " FROM z3950servers";
|
||||
if ( $searchstring ne '' ) { $query .= " WHERE (name like ?)" }
|
||||
$query .= " ORDER BY rank,name";
|
||||
|
|
@ -52,6 +52,7 @@ sub StringSearch {
|
|||
else {
|
||||
$sth->execute;
|
||||
}
|
||||
|
||||
my @results;
|
||||
while (my $data=$sth->fetchrow_hashref) {
|
||||
push(@results,$data);
|
||||
|
|
@ -91,13 +92,13 @@ if ($op eq 'add_form') {
|
|||
my $data;
|
||||
if ($searchfield) {
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth=$dbh->prepare("select host,port,db,userid,password,name,id,checked,rank,syntax,encoding from z3950servers where (name = ?) order by rank,name");
|
||||
my $sth=$dbh->prepare("select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout from z3950servers where (name = ?) order by rank,name");
|
||||
$sth->execute($searchfield);
|
||||
$data=$sth->fetchrow_hashref;
|
||||
$sth->finish;
|
||||
}
|
||||
$template->param( $_ => $data->{$_} )
|
||||
for ( qw( host port db userid password checked rank ) );
|
||||
for ( qw( host port db userid password checked rank timeout ) );
|
||||
$template->param( $_ . $data->{$_} => 1)
|
||||
for ( qw( syntax encoding ) );
|
||||
# END $OP eq ADD_FORM
|
||||
|
|
@ -110,7 +111,7 @@ if ($op eq 'add_form') {
|
|||
$sth->execute($input->param('searchfield'));
|
||||
my $checked = $input->param('checked') ? 1 : 0;
|
||||
if ($sth->rows) {
|
||||
$sth=$dbh->prepare("update z3950servers set host=?, port=?, db=?, userid=?, password=?, name=?, checked=?, rank=?,syntax=?,encoding=? where name=?");
|
||||
$sth=$dbh->prepare("update z3950servers set host=?, port=?, db=?, userid=?, password=?, name=?, checked=?, rank=?,syntax=?,encoding=?,timeout=? where name=?");
|
||||
$sth->execute($input->param('host'),
|
||||
$input->param('port'),
|
||||
$input->param('db'),
|
||||
|
|
@ -121,14 +122,15 @@ if ($op eq 'add_form') {
|
|||
$input->param('rank'),
|
||||
$input->param('syntax'),
|
||||
$input->param('encoding'),
|
||||
$input->param('timeout'),
|
||||
$input->param('searchfield'),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$sth=$dbh->prepare(
|
||||
"INSERT INTO z3950servers " .
|
||||
"(host,port,db,userid,password,name,checked,rank,syntax,encoding) " .
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" );
|
||||
"(host,port,db,userid,password,name,checked,rank,syntax,encoding,timeout) " .
|
||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" );
|
||||
$sth->execute(
|
||||
$input->param( 'host' ),
|
||||
$input->param( 'port' ),
|
||||
|
|
@ -139,6 +141,7 @@ if ($op eq 'add_form') {
|
|||
$checked,
|
||||
$input->param( 'rank' ),
|
||||
$input->param( 'syntax' ),
|
||||
$input->param( 'timeout' ),
|
||||
$input->param( 'encoding' ) );
|
||||
}
|
||||
$sth->finish;
|
||||
|
|
@ -149,7 +152,7 @@ if ($op eq 'add_form') {
|
|||
$template->param(delete_confirm => 1);
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
my $sth2=$dbh->prepare("select host,port,db,userid,password,name,id,checked,rank,syntax,encoding from z3950servers where (name = ?) order by rank,name");
|
||||
my $sth2=$dbh->prepare("select host,port,db,userid,password,name,id,checked,rank,syntax,encoding,timeout from z3950servers where (name = ?) order by rank,name");
|
||||
$sth2->execute($searchfield);
|
||||
my $data=$sth2->fetchrow_hashref;
|
||||
$sth2->finish;
|
||||
|
|
@ -162,6 +165,7 @@ if ($op eq 'add_form') {
|
|||
checked => $data->{'checked'},
|
||||
rank => $data->{'rank'},
|
||||
syntax => $data->{'syntax'},
|
||||
timeout => $data->{'timeout'},
|
||||
encoding => $data->{'encoding'} );
|
||||
|
||||
# END $OP eq DELETE_CONFIRM
|
||||
|
|
@ -192,7 +196,8 @@ if ($op eq 'add_form') {
|
|||
checked => $results->[$i]{'checked'},
|
||||
rank => $results->[$i]{'rank'},
|
||||
syntax => $results->[$i]{'syntax'},
|
||||
encoding => $results->[$i]{'encoding'});
|
||||
encoding => $results->[$i]{'encoding'},
|
||||
timeout => $results->[$i]{'timeout'});
|
||||
push @loop, \%row;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,6 +179,7 @@ warn "query ".$query if $DEBUG;
|
|||
$option1->option('user', $server->{userid} ) if $server->{userid};
|
||||
$option1->option('password', $server->{password}) if $server->{password};
|
||||
$option1->option('preferredRecordSyntax', $server->{syntax});
|
||||
$option1->option( 'timeout', $server->{timeout} ) if ($server->{timeout});
|
||||
$oConnection[$s] = create ZOOM::Connection($option1)
|
||||
|| $DEBUG
|
||||
&& warn( "" . $oConnection[$s]->errmsg() );
|
||||
|
|
@ -222,7 +223,7 @@ warn "query ".$query if $DEBUG;
|
|||
$oConnection[$k]->error_x();
|
||||
if ($error) {
|
||||
if ($error =~ m/^(10000|10007)$/ ) {
|
||||
push(@errconn, {'server' => $serverhost[$k]});
|
||||
push(@errconn, {'server' => $serverhost[$k], 'error' => $error});
|
||||
}
|
||||
$DEBUG and warn "$k $serverhost[$k] error $query: $errmsg ($error) $addinfo\n";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2118,6 +2118,7 @@ CREATE TABLE `z3950servers` ( -- connection information for the Z39.50 targets u
|
|||
`checked` smallint(6) default NULL, -- whether this target is checked by default (1 for yes, 0 for no)
|
||||
`rank` int(11) default NULL, -- where this target appears in the list of targets
|
||||
`syntax` varchar(80) default NULL, -- marc format provided by this target
|
||||
`timeout` int(11) NOT NULL DEFAULT '0',
|
||||
`icon` text, -- unused in Koha
|
||||
`position` enum('primary','secondary','') NOT NULL default 'primary',
|
||||
`type` enum('zed','opensearch') NOT NULL default 'zed',
|
||||
|
|
|
|||
|
|
@ -5027,6 +5027,15 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
|
|||
SetVersion($DBversion);
|
||||
}
|
||||
|
||||
$DBversion = "3.07.00.xxx";
|
||||
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
|
||||
$dbh->do(qq{
|
||||
ALTER TABLE `z3950servers` ADD `timeout` INT( 11 ) NOT NULL DEFAULT '0' AFTER `syntax`;
|
||||
});
|
||||
print "Upgrade to $DBversion done (New timeout field in z3950servers)\n";
|
||||
SetVersion($DBversion);
|
||||
}
|
||||
|
||||
=head1 FUNCTIONS
|
||||
|
||||
=head2 DropAllForeignKeys($table)
|
||||
|
|
|
|||
|
|
@ -230,6 +230,9 @@
|
|||
[% END %]
|
||||
</select>
|
||||
</li>
|
||||
<li><label for="timeout">Timeout (0 its like not set): </label>
|
||||
<input type="text" name="timeout" id="timeout" size="4" value="[% timeout %]" onblur="isNum(this)" /> seconds
|
||||
</li>
|
||||
</ol>
|
||||
</fieldset>
|
||||
|
||||
|
|
@ -258,6 +261,7 @@
|
|||
<li><strong>Rank: </strong>[% rank %]</li>
|
||||
<li><strong>Syntax: </strong>[% syntax %]</li>
|
||||
<li><strong>Encoding: </strong>[% encoding %]</li>
|
||||
<li><strong>Timeout: </strong>[% timeout %]</li>
|
||||
</ul> <form action="[% script_name %]" method="post"><input type="hidden" name="op" value="delete_confirmed" /><input type="hidden" name="searchfield" value="[% searchfield %]" /><input type="submit" value="Delete this Server" /></form> <form action="[% script_name %]" method="post"><input type="submit" value="Do Not Delete" /></form>
|
||||
|
||||
|
||||
|
|
@ -301,7 +305,7 @@
|
|||
You searched for [% searchfield %]
|
||||
[% END %]
|
||||
<table id="serverst">
|
||||
<thead><tr><th>Target</th><th>Hostname/Port</th><th>Database</th><th>Userid</th><th>Password</th><th>Checked</th><th>Rank</th> <th>Syntax</th><th>Encoding</th><th colspan="2"> </th>
|
||||
<thead><tr><th>Target</th><th>Hostname/Port</th><th>Database</th><th>Userid</th><th>Password</th><th>Checked</th><th>Rank</th> <th>Syntax</th><th>Encoding</th><th>Timeout</th><th colspan="2"> </th>
|
||||
</tr></thead>
|
||||
<tbody>[% FOREACH loo IN loop %]
|
||||
[% UNLESS ( loop.odd ) %]
|
||||
|
|
@ -309,7 +313,7 @@
|
|||
[% ELSE %]
|
||||
<tr>
|
||||
[% END %]
|
||||
<td><a href="[% loo.script_name %]?op=add_form&searchfield=[% loo.name |url %]">[% loo.name %]</a></td><td>[% loo.host %]:[% loo.port %]</td><td>[% loo.db %]</td><td>[% loo.userid %]</td><td>[% loo.password %]</td><td>[% IF ( loo.checked ) %]Yes[% ELSE %]No[% END %]</td><td>[% loo.rank %]</td> <td>[% loo.syntax %]</td><td>[% loo.encoding %]</td><td><a href="[% loo.script_name %]?op=add_form&searchfield=[% loo.name |url %]">Edit</a></td><td><a href="[% loo.script_name %]?op=delete_confirm&searchfield=[% loo.name |url %]">Delete</a></td> </tr>
|
||||
<td><a href="[% loo.script_name %]?op=add_form&searchfield=[% loo.name |url %]">[% loo.name %]</a></td><td>[% loo.host %]:[% loo.port %]</td><td>[% loo.db %]</td><td>[% loo.userid %]</td><td>[% loo.password %]</td><td>[% IF ( loo.checked ) %]Yes[% ELSE %]No[% END %]</td><td>[% loo.rank %]</td> <td>[% loo.syntax %]</td><td>[% loo.encoding %]</td><td>[% loo.timeout %]</td><td><a href="[% loo.script_name %]?op=add_form&searchfield=[% loo.name |url %]">Edit</a></td><td><a href="[% loo.script_name %]?op=delete_confirm&searchfield=[% loo.name |url %]">Delete</a></td> </tr>
|
||||
[% END %]</tbody>
|
||||
</table>
|
||||
|
||||
|
|
|
|||
|
|
@ -166,7 +166,8 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color :
|
|||
<div class="dialog alert">
|
||||
<ul>
|
||||
[% FOREACH errcon IN errconn %]
|
||||
<li>Connection failed to [% errcon.server %]</li>
|
||||
[% IF ( errcon.error == '10000' ) %]<li>Connection failed to [% errcon.server %]</li>
|
||||
[% ELSIF ( errcon.error == '10007' ) %]<li>Connection timeout to [% errcon.server %]</li>[% END %]
|
||||
[% END %]
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue