Skip to content

Commit

Permalink
Fix z3950_client: incorrect waiting for max-sockets condition MP-652
Browse files Browse the repository at this point in the history
The z3950_client could in some cases wait a very long time for a free
Z39.50 socket. The proper behavior is to give up after 15 seconds.
  • Loading branch information
adamdickmeiss committed Aug 29, 2017
1 parent 8658066 commit 41e3d5c
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/filter_z3950_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,15 @@ yf::Z3950Client::Assoc *yf::Z3950Client::Rep::get_assoc(Package &package)
}

// see if we have reached max number of clients (max-sockets)

boost::xtime xt;
xtime_get(&xt,
#if BOOST_VERSION >= 105000
boost::TIME_UTC_
#else
boost::TIME_UTC
#endif
);
xt.sec += 15;
while (max_sockets)
{
int no_not_in_use = 0;
Expand Down Expand Up @@ -450,16 +458,6 @@ yf::Z3950Client::Assoc *yf::Z3950Client::Rep::get_assoc(Package &package)
package.session().close();
return 0;
}
boost::xtime xt;
xtime_get(&xt,
#if BOOST_VERSION >= 105000
boost::TIME_UTC_
#else
boost::TIME_UTC
#endif
);

xt.sec += 15;
if (!m_cond_session_ready.timed_wait(lock, xt))
{
mp::odr odr;
Expand Down

0 comments on commit 41e3d5c

Please sign in to comment.