[freetds] new network timeout code
James K. Lowden
jklowden at freetds.org
Tue Jan 9 00:12:38 EST 2007
ZIGLIO, Frediano, VF-IT wrote:
> >
> Is underscore part of libTDS function prefix?
> Is underscore part of libTDS enumeration prefix?
Fair questions. I'm thinking about it. Certainly all the existing libtds
stuff has underscores. Maybe it should be tds_perror().
> > Do you think it's possible for tds_select to call
> > tds_send_cancel? If so,
> > tds_select need return only >1 (OK) or <1 (FAIL).
>
> Mmmm... I think you should check what happen if tds_send_cancel is
> called inside tds_goodwrite writing another packet... I think that in
> this situation we could send garbage...
Ah. Must let higher level decide when to call tds_send_cancel.
> I think that setting query_timeout to 1 and selecting interrupt/error
> handler in dblib could lead to a unique libTDS handler. But perhaps now
> is better to finish stuff with libTDS interrupt handler.
Agreed. See also dbsetbusy and dbsetidle in Sybase's db-lib.
> - on timeout we call tdserror than later on caller (tds_goodread or
> tds_goodwrite) we call tdserror again
I removed the outer loop in tds_select; it no longer calls tdserror.
> - we can avoid to compute tv if ptv is NULL
> - we should avoid to call tds_gettime_ms twice
> - tv_usec unit is microseconds so milliseconds should be multiplied by
> 1000
> - I don't understand tv.tv_sec + tv.tv_usec > 0 condition
>
> Perhaps this would be easier
[excellent code snipped]
I tried a few different ways. Yours was best. Showoff. ;-)
> Yes, but you can disable assert with -DNDEBUG while you can't disable
> perror.
Good point. Removed.
> Perhaps however when someone will read documentation will ask... What's
> sock_errno? Perhaps should we specify errno on POSIX and
> WSAGetLastError() on Windows? And under cygwin?
I think the code is easier to read as is. It's a shame we can't just
#define errno WSAGetLastError()
> Well... now I understand the recursion... a timeout inside
> tds_send_cancel (however tds_send_cancel can't recurse). I'm more aware
> of a tds_send_cancel while sending a packet. Does this work correctly?
I don't know yet. I'll be sure to include it in my unit test.
> Does even a tds_send_cancel inside a signal is correct?
If we're *very* careful. The set of libc functions that are signal safe
is small.
Regards,
--jkl
More information about the FreeTDS
mailing list