Add connect_timeout= option

This commit is contained in:
Richard Frith-Macdonald 2023-08-16 16:22:29 +01:00
parent 14dcbf5c7f
commit 218578aa95
2 changed files with 15 additions and 1 deletions

View file

@ -1,3 +1,8 @@
2023-08-16 Richard Frith-Macdonald <rfm@gnu.org>
* Postgres.m: Implement support for connect_timeoout= option to
control how long we allow for a connection attempt to a host.
2023-01-13 Richard Frith-Macdonald <rfm@gnu.org>
* GNUmakefile: bumped version to 1.9.0.

View file

@ -393,7 +393,8 @@ connectQuote(NSString *str)
NSString *host = nil;
NSString *port = nil;
NSString *dbase = [self database];
NSString *sslmode = [options objectForKey: @"sslmode"];
NSString *sslmode;
int timeout;
NSString *str;
NSRange r;
NSRange pwRange = NSMakeRange(NSNotFound, 0);
@ -457,6 +458,8 @@ connectQuote(NSString *str)
[m appendString: @" application_name="];
[m appendString: str];
}
sslmode = [options objectForKey: @"sslmode"];
if ([sslmode isEqual: @"require"])
{
str = connectQuote(@"require");
@ -467,6 +470,12 @@ connectQuote(NSString *str)
}
}
timeout = [[options objectForKey: @"connect_timeout"] intValue];
if (timeout > 0)
{
[m appendFormat: @" connect_timeout=%d", timeout];
}
if ([self debugging] > 0)
{
[self debug: @"Connect to '%@' as %@ (%@)",