I created the following problem:

Host A runs my software that uses libdbi. Host B it's the database 
server (MySQL one, for now is in the same LAN with Host A).

I have a thread that receive a linked list with the data that has to be 
written to the database. At every 5 minutes, this thread is created and 
runs until it finish the inserts, then terminates.

On the Host B (the db one) I'm using iptables to simulate the network 
down problem, like:

iptables -A INPUT -s IP_OF_HOST_A -p tcp --dport 3306 -j REJECT 
--reject-with icmp-host-unreachable

This generates ICMP packets simulating that host has gone away, if 
packets arrive on 3306.

In the writing thread I have a simple:

res = dbi_conn_query (...);

When the program call the function it blocks for unlimited amount of 
time (as much as I leave the REJECT rule on the DB host)...

There is a way to make somehow a kind of timeout? A timer and killing 
the thread it's not a clean solution... Or there is a parameter that 
can be set? Or I have to hack in the libdbi source code?

I'm using persistent connection (connection is made at the start of the 
program). I don't know if: connect, do job, disconnect it's a good 
solution also...

  Claudiu Cismaru
  GPG Key: http://maya.cnixs.com/~claudiu/claudiu.gpg

Attachment: pgpQlSHSRNs6E.pgp
Description: PGP signature

Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
libdbi-users mailing list

Reply via email to