Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: cancel and timeout: msg#00133

db.tds.freetds

Subject: Re: cancel and timeout

On Thu, 20 Jan 2005 17:11:12 -0000, "Thompson, Bill D (London)"
<bill_d_thompson@xxxxxx> wrote:
> > Timeout
> > -------
> > Now if a timeout (now query_timeout) a query_timeout_func it's called.
> I
> > removed chkintr and hndlintr (one function it's sufficient).
> > query_start_time it's use for global time counting. I don't know if
> > query timeout on dblib works as expected. Perhaps even SQLFetch or
> > similar need setting timeout.
>
> I think there are two functions because this then mirrors the dblibrary
> interrupt handlers.

Thanks for tackling this, Freddy.

I think Bill means:

void dbsetinterrupt(dbproc, chkintr, hndlintr)

DBPROCESS *dbproc;
int (*chkintr)();
int (*hndlintr)();

http://sybooks.sybase.com/onlinebooks/group-cnarc/cng1000e/dblib/@Generic__BookTextView/34848;pt=34848;uf=0#X


Note the comment:

"DB-Library does non-blocking reads from the server. While waiting for a
read from the server, it will call the chkintr() function to see if an
interrupt is pending. If chkintr() returns TRUE and a handler has been
installed as the hndlintr() for dbsetinterrupt, hndlintr() will be
called."

That's not how dblib_query_timeout() is currently coded. chkintr should
be called periodically from within src/tds/net.c::goodread() until either:

1. the server sends data, or
2. the query_timeout expires.

goodread() calls hndlintr after the timeout. It should call it while
counting down to the timeout. How often? The docs don't say. They say
they (Sybase) do non-blocking I/O, implying a busy wait. I think it would
be OK to call select(2) with a timeout of, say, 100 ms (blocking), then
call hndlintr, then busyfunc, then deduct 100 ms from query_timeout, and
call select(2) again. Something like:

for (ti = selecttimeout;
retcode = select(tds->s + 1, &fds, NULL, NULL, ti);
ti.tv_usec -= 100)
{
if (retcode < 0) {
/* error */
}
if (retcode > 0) {
break; /* data ready: read */
}
assert(retcode == 0); /* partial timeout */
if (ti.tv_usec < 0) {
ti.tv_sec--;
ti.tv_usec += 1000;
}

if (ti.tv_sec < 0) break; /* really timed out */

if ((*tds->chkintr)())
(*tds->hndlintr());
if (tds->busyfunc)
(*tds->busyfunc)();
}

len = READSOCKET(tds->s, buf + got, buflen);

if (tds->idlefunc)
(*tds->idlefunc)();


These may also be interesting:

dbsetidle:
http://sybooks.sybase.com/onlinebooks/group-cnarc/cng1000e/dblib/@Generic__BookTextView/34650;pt=3564

"idlefunc() will be automatically called whenever DB-Library has finished
reading output from the server."

dbsetbusy:
http://sybooks.sybase.com/onlinebooks/group-cnarc/cng1000e/dblib/@Generic__BookTextView/34263;pt=34263;uf=0#X

"automatically called whenever DB-Library is reading or waiting to read
output from the server."

--jkl


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
qnx.openqnx.dev...    gcc.libstdc++.c...    solaris.opensol...    information-ret...    misc.misterhous...    web.catalyst.ge...    apache.webservi...    redhat.release....    hardware.lirc/2...    kernel.autofs/2...    technology.sust...    linux.vdr/2003-...    editors.lyx.gen...    org.user-groups...    netbsd.devel.pk...    xdg.devel/2004-...    version-control...    jakarta.slide.d...    debian.packages...    creativecommons...    ports.ppc.embed...    bug-tracking.bu...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe