Re: [Sqlrelay-discussion] setConnectTimeout() not working correctly?
Brought to you by:
mused
From: Cal H. <ca...@fb...> - 2014-01-06 21:09:16
|
Hi David, Yes, that appears to work as expected. Thanks for the quick fix! --Cal On Wed, Jan 1, 2014 at 5:41 PM, David Muse <dav...@fi...>wrote: > Hi Cal, > > It looks like I forgot to flip the sense of an if when I un-nested its > contents. > > It'll be fixed in the next release of sqlrelay/rudiments, but for a > quick fix... > > In the rudiments library, edit src/socketclient.cpp (or if you're using > an older version, src/clientsocket.cpp) and look for an if statement > like this, near line 235: > > if (error::getErrorNumber()==EINPROGRESS || > error::getErrorNumber()==EWOULDBLOCK) { > retval=RESULT_ERROR; > goto cleanup; > } > > Change it to: > > if (error::getErrorNumber()!=EINPROGRESS && > error::getErrorNumber()!=EWOULDBLOCK) { > retval=RESULT_ERROR; > goto cleanup; > } > > Note the !='s rather than =='s and && rather than ||. > > Recompile and reinstall rudiments: > > make > sudo make install > > And it should work. > > Let me know if you run into any more problems. > > And thanks for finding that bug! > > Dave > dav...@fi... > > On 1/1/2014 6:23 PM, David Muse wrote: > > Hi Cal, > > > > Interesting... I'll do some tests here, figure out what's happening and > > let you know what I find. > > > > Dave > > > > On 12/31/2013 3:08 PM, Cal Heldenbrand wrote: > >> Hi David, > >> > >> I'm attempting to write a weighted round-robin connection method for an > >> easy failover mechanism on multiple SQL Relay servers. It appears that > >> the C++ sqlrconnection::setConnectTimeout() function isn't behaving like > >> I'd expect. It seems that no matter what values I pass to it, the > >> connection *always* fails. > >> > >> Here's the general idea I'm doing: > >> > >> bool success = false; > >> do > >> { > >> /* > >> select random sql relay server > >> */ > >> > >> tmpconn = new sqlrconnection(hostname, port, NULL, > >> user, pass, 0, 1); > >> tmpconn->debugOn(); > >> tmpconn->setConnectTimeout(10, 5000000); > >> > >> const char *version = tmpconn->serverVersion(); > >> printf("version: '%s'\n", version); > >> if ( version ) > >> success = true; > >> > >> /* Breaking out after a few tries */ > >> } > >> while ( success == false ); > >> > >> Running that, I get something like this: > >> > >> <pre> > >> Connecting to listener... > >> </pre> > >> <pre> > >> Inet socket: 127.0.0.1:9000 <http://127.0.0.1:9000> > >> </pre> > >> <pre> > >> Setting Error > >> </pre> > >> <pre> > >> Couldn't connect to the listener. > >> </pre> > >> version: '(null)' > >> > >> But when I comment out the setConnectTimeout() call, it works just fine: > >> > >> <pre> > >> Connecting to listener... > >> </pre> > >> <pre> > >> Inet socket: 127.0.0.1:9000 <http://127.0.0.1:9000> > >> </pre> > >> <pre> > >> Authenticating : ... > >> </pre> > >> <pre> > >> Server Version... > >> </pre> > >> <pre> > >> Checking for error > >> </pre> > >> <pre> > >> No error occurred > >> </pre> > >> <pre> > >> 0.53.1 > >> </pre> > >> version: '0.53.1' > >> > >> I've played around with different values for seconds and microseconds. > >> (I want a timeout of 5 seconds, however that can be accomplished) > >> > >> Thanks for any help! > >> > >> --Cal > >> > >> > >> > ------------------------------------------------------------------------------ > >> > >> Rapidly troubleshoot problems before they affect your business. Most IT > >> organizations don't have a clear picture of how application performance > >> affects their revenue. With AppDynamics, you get 100% visibility into > >> your > >> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of > >> AppDynamics Pro! > >> > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk > >> > >> > >> _______________________________________________________ > >> Unlimited Disk, Data Transfer, PHP/MySQL Domain Hosting > >> http://www.doteasy.com > >> > >> > >> > >> _______________________________________________ > >> Sqlrelay-discussion mailing list > >> Sql...@li... > >> https://lists.sourceforge.net/lists/listinfo/sqlrelay-discussion > >> > >> > >> _______________________________________________________ > >> Unlimited Disk, Data Transfer, PHP/MySQL Domain Hosting > >> http://www.doteasy.com > >> > > > ------------------------------------------------------------------------------ > Rapidly troubleshoot problems before they affect your business. Most IT > organizations don't have a clear picture of how application performance > affects their revenue. With AppDynamics, you get 100% visibility into your > Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics > Pro! > http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk > _______________________________________________ > Sqlrelay-discussion mailing list > Sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlrelay-discussion > |