Joe Beanfish <(E-Mail Removed)> writes:
> Florian Erfurth wrote:
>> David Schwartz wrote:
>>
>>> On Mar 27, 3:55 am, Florian Erfurth <floh-erfu...@arcor.de> wrote:
>>>
>>>> This seems to be ok. On my workstation I tried the same, but the content
>>>> of 'route -n' is unchanged before and after unplugging.
>>> You are never guaranteed that the loss of a link will be detectable.
>>> Links can fail in both detectable and undetectable ways.
>>>
>>> Figure out why your application is hanging, rather than detecting that
>>> it cannot reach the other side, and fix the application.
>> Sure I should fix my application, but how? Here is the part of the code:
>>
>> if(mysql_real_connect(Connection, "192.168.0.2", "user",
>> "password", "database", 0, NULL, 0))
>> {
>> printf("\033[0;93m Connection was successful! \033[0m\n");
>> mysql_close(Connection);
>> }
>> else
>> printf("\033[0;93m Connection failed!!! \033[0m\n");
>>
>> If I unplug ethernet cable on my laptop, the application replys
>> "Connection failed!!!" at once. On Workstation the app freezes at
>> mysql_real_connect() and after ca. 1,5minutes(!) I got the reply
>> "Connection failed!!!". I already tried with Timeout=5sec but it
>> doesn't help.
>
> That sounds perfectly normal and ok to me. But if you want to be friendlier
> about it you could try pinging before connect. But who's to say that someone
> won't chop the cable after you've connected while you're trying to execute
> sql? Then you're in as bad or worse shape. Your app must be able to handle
> network failures.
His application is handling network failures as well as it can under
the circumstances: the mysql client library is waiting a long, long
time to timeout when the network is disconnected, after which his
application is finally able to do something reasonable.
Increasing the probability that the timeout will be much shorter is a
good thing to do, and is the direction he's headed.
|