aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/PostgresKit/Source/PGPostgresConnection.m
diff options
context:
space:
mode:
Diffstat (limited to 'Frameworks/PostgresKit/Source/PGPostgresConnection.m')
-rw-r--r--Frameworks/PostgresKit/Source/PGPostgresConnection.m102
1 files changed, 50 insertions, 52 deletions
diff --git a/Frameworks/PostgresKit/Source/PGPostgresConnection.m b/Frameworks/PostgresKit/Source/PGPostgresConnection.m
index 600be9a0..5e1ac2bf 100644
--- a/Frameworks/PostgresKit/Source/PGPostgresConnection.m
+++ b/Frameworks/PostgresKit/Source/PGPostgresConnection.m
@@ -297,64 +297,62 @@ static void _PGPostgresConnectionNoticeProcessor(void *arg, const char *message)
*/
- (void)_pollConnection:(NSNumber *)isReset
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- BOOL reset = isReset && [isReset boolValue];
-
- int sock = PQsocket(_connection);
-
- if (sock == -1) {
- [pool release];
- return;
- }
-
- struct pollfd fdinfo[1];
-
- fdinfo[0].fd = sock;
- fdinfo[0].events = POLLIN|POLLOUT;
-
- PostgresPollingStatusType status;
-
- do
- {
- status = reset ? PQresetPoll(_connection) : PQconnectPoll(_connection);
-
- if (status == PGRES_POLLING_READING || status == PGRES_POLLING_WRITING) {
- if (poll(fdinfo, 1, -1) < 0) break;
- }
- }
- while (status != PGRES_POLLING_OK && status != PGRES_POLLING_FAILED);
-
- if (status == PGRES_POLLING_OK && [self isConnected]) {
-
- // Increase error verbosity
- PQsetErrorVerbosity(_connection, PQERRORS_VERBOSE);
-
- // Set notice processor
- PQsetNoticeProcessor(_connection, _PGPostgresConnectionNoticeProcessor, self);
-
- // Register or clear type extensions
- NSInteger success = reset ? PQclearTypes(_connection) : PQinitTypes(_connection);
-
- if (!success) {
- NSLog(@"PostgresKit: Error: Failed to initialise or clear type extensions. Connection might return unexpected results!");
+ @autoreleasepool {
+ BOOL reset = isReset && [isReset boolValue];
+
+ int sock = PQsocket(_connection);
+
+ if (sock == -1) {
+ [pool release];
+ return;
}
-
- [self _loadDatabaseParameters];
-
- if (reset) {
- if (_delegate && [_delegate respondsToSelector:@selector(connectionReset:)]) {
- [_delegate performSelectorOnMainThread:@selector(connectionReset:) withObject:self waitUntilDone:NO];
+
+ struct pollfd fdinfo[1];
+
+ fdinfo[0].fd = sock;
+ fdinfo[0].events = POLLIN|POLLOUT;
+
+ PostgresPollingStatusType status;
+
+ do
+ {
+ status = reset ? PQresetPoll(_connection) : PQconnectPoll(_connection);
+
+ if (status == PGRES_POLLING_READING || status == PGRES_POLLING_WRITING) {
+ if (poll(fdinfo, 1, -1) < 0) break;
}
}
- else {
- if (_delegate && [_delegate respondsToSelector:@selector(connectionEstablished:)]) {
- [_delegate performSelectorOnMainThread:@selector(connectionEstablished:) withObject:self waitUntilDone:NO];
+ while (status != PGRES_POLLING_OK && status != PGRES_POLLING_FAILED);
+
+ if (status == PGRES_POLLING_OK && [self isConnected]) {
+
+ // Increase error verbosity
+ PQsetErrorVerbosity(_connection, PQERRORS_VERBOSE);
+
+ // Set notice processor
+ PQsetNoticeProcessor(_connection, _PGPostgresConnectionNoticeProcessor, self);
+
+ // Register or clear type extensions
+ NSInteger success = reset ? PQclearTypes(_connection) : PQinitTypes(_connection);
+
+ if (!success) {
+ NSLog(@"PostgresKit: Error: Failed to initialise or clear type extensions. Connection might return unexpected results!");
+ }
+
+ [self _loadDatabaseParameters];
+
+ if (reset) {
+ if (_delegate && [_delegate respondsToSelector:@selector(connectionReset:)]) {
+ [_delegate performSelectorOnMainThread:@selector(connectionReset:) withObject:self waitUntilDone:NO];
+ }
+ }
+ else {
+ if (_delegate && [_delegate respondsToSelector:@selector(connectionEstablished:)]) {
+ [_delegate performSelectorOnMainThread:@selector(connectionEstablished:) withObject:self waitUntilDone:NO];
+ }
}
}
}
-
- [pool release];
}
/**