@@ -297,64 +297,62 @@ - (BOOL)cancelCurrentQuery:(NSError **)error
297
297
*/
298
298
- (void )_pollConnection : (NSNumber *)isReset
299
299
{
300
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc ] init ];
301
-
302
- BOOL reset = isReset && [isReset boolValue ];
303
-
304
- int sock = PQsocket (_connection);
305
-
306
- if (sock == -1 ) {
307
- [pool release ];
308
- return ;
309
- }
310
-
311
- struct pollfd fdinfo[1 ];
312
-
313
- fdinfo[0 ].fd = sock;
314
- fdinfo[0 ].events = POLLIN|POLLOUT;
315
-
316
- PostgresPollingStatusType status;
317
-
318
- do
319
- {
320
- status = reset ? PQresetPoll (_connection) : PQconnectPoll (_connection);
321
-
322
- if (status == PGRES_POLLING_READING || status == PGRES_POLLING_WRITING) {
323
- if (poll (fdinfo, 1 , -1 ) < 0 ) break ;
324
- }
325
- }
326
- while (status != PGRES_POLLING_OK && status != PGRES_POLLING_FAILED);
327
-
328
- if (status == PGRES_POLLING_OK && [self isConnected ]) {
329
-
330
- // Increase error verbosity
331
- PQsetErrorVerbosity (_connection, PQERRORS_VERBOSE);
332
-
333
- // Set notice processor
334
- PQsetNoticeProcessor (_connection, _PGPostgresConnectionNoticeProcessor, self);
335
-
336
- // Register or clear type extensions
337
- NSInteger success = reset ? PQclearTypes (_connection) : PQinitTypes (_connection);
338
-
339
- if (!success) {
340
- NSLog (@" PostgresKit: Error: Failed to initialise or clear type extensions. Connection might return unexpected results!" );
300
+ @autoreleasepool {
301
+ BOOL reset = isReset && [isReset boolValue ];
302
+
303
+ int sock = PQsocket (_connection);
304
+
305
+ if (sock == -1 ) {
306
+ [pool release ];
307
+ return ;
341
308
}
342
-
343
- [self _loadDatabaseParameters ];
344
-
345
- if (reset) {
346
- if (_delegate && [_delegate respondsToSelector: @selector (connectionReset: )]) {
347
- [_delegate performSelectorOnMainThread: @selector (connectionReset: ) withObject: self waitUntilDone: NO ];
309
+
310
+ struct pollfd fdinfo[1 ];
311
+
312
+ fdinfo[0 ].fd = sock;
313
+ fdinfo[0 ].events = POLLIN|POLLOUT;
314
+
315
+ PostgresPollingStatusType status;
316
+
317
+ do
318
+ {
319
+ status = reset ? PQresetPoll (_connection) : PQconnectPoll (_connection);
320
+
321
+ if (status == PGRES_POLLING_READING || status == PGRES_POLLING_WRITING) {
322
+ if (poll (fdinfo, 1 , -1 ) < 0 ) break ;
348
323
}
349
324
}
350
- else {
351
- if (_delegate && [_delegate respondsToSelector: @selector (connectionEstablished: )]) {
352
- [_delegate performSelectorOnMainThread: @selector (connectionEstablished: ) withObject: self waitUntilDone: NO ];
325
+ while (status != PGRES_POLLING_OK && status != PGRES_POLLING_FAILED);
326
+
327
+ if (status == PGRES_POLLING_OK && [self isConnected ]) {
328
+
329
+ // Increase error verbosity
330
+ PQsetErrorVerbosity (_connection, PQERRORS_VERBOSE);
331
+
332
+ // Set notice processor
333
+ PQsetNoticeProcessor (_connection, _PGPostgresConnectionNoticeProcessor, self);
334
+
335
+ // Register or clear type extensions
336
+ NSInteger success = reset ? PQclearTypes (_connection) : PQinitTypes (_connection);
337
+
338
+ if (!success) {
339
+ NSLog (@" PostgresKit: Error: Failed to initialise or clear type extensions. Connection might return unexpected results!" );
340
+ }
341
+
342
+ [self _loadDatabaseParameters ];
343
+
344
+ if (reset) {
345
+ if (_delegate && [_delegate respondsToSelector: @selector (connectionReset: )]) {
346
+ [_delegate performSelectorOnMainThread: @selector (connectionReset: ) withObject: self waitUntilDone: NO ];
347
+ }
348
+ }
349
+ else {
350
+ if (_delegate && [_delegate respondsToSelector: @selector (connectionEstablished: )]) {
351
+ [_delegate performSelectorOnMainThread: @selector (connectionEstablished: ) withObject: self waitUntilDone: NO ];
352
+ }
353
353
}
354
354
}
355
355
}
356
-
357
- [pool release ];
358
356
}
359
357
360
358
/* *
0 commit comments