Commits

Tuukka Norri committed 0d71552

Even more work on SSL support and other fixes
- Moved interface specific methods from BXDatabaseContext.h to BXInterface.h.
- Changed -connectAsyncIfNeeded to -connect.
- Invalid trust now gets handled differently for synchronous and asynchronous connection attempts (it did earlier but incorrectly).
- Added a Cancel button to the certificate trust panel.

  • Participants
  • Parent commits da772a2
  • Branches PGTS

Comments (0)

Files changed (4)

File Framework/Sources/PGTSConnection.h

 	volatile BOOL shouldContinueThread;
     volatile BOOL threadRunning;
     volatile BOOL failedToSendQuery;
+	
     volatile BOOL messageDelegateAfterConnecting;
 	volatile BOOL sslSetUp;
+	BOOL connecting;
+	BOOL connectingAsync;
 }
 
 + (PGTSConnection *) connection;
 
 - (id <PGTSCertificateVerificationDelegate>) certificateVerificationDelegate;
 - (void) setCertificateVerificationDelegate: (id <PGTSCertificateVerificationDelegate>) anObject;
+
+- (BOOL) connectingAsync;
 @end
 
 

File Framework/Sources/PGTSConnection.m

     BOOL rval = NO;
     CheckExceptionTable (self, kPGTSRaiseForConnectAsync, messageDelegateAfterConnecting);
 
+	if (NO == connecting)
+	{
+		connecting = YES;
+		connectingAsync = YES;
+	}
+	
 	[connectionLock lock];
 	if (NULL != connection)
 	{
 		rval = YES;
 		[workerProxy workerPollConnectionResetting: NO];
 	}
+	else
+	{
+		connecting = NO;
+	}
+	
     return rval;
 }
 
 //@{
 - (ConnStatusType) connect
 {
-    BlockWhileConnecting ([self connectAsync]);    
+	connecting = YES;
+    BlockWhileConnecting ([self connectAsync]);
+	connecting = NO;
     return connectionStatus;
 }
 
 	if (nil == certificateVerificationDelegate)
 		certificateVerificationDelegate = defaultCertDelegate;
 }
+
+- (BOOL) connectingAsync
+{
+	return (connecting && connectingAsync);
+}
 @end
 
 

File Framework/Sources/PGTSConnectionPrivate.m

  */
 - (void) finishConnecting
 {
+	connecting = NO;
     if (CONNECTION_OK != connectionStatus)
         [[PGTSConnectionPool sharedInstance] removeConnection: self];
     else

File Framework/libpq.patch

  					/* SSL handshake done, ready to send startup packet */
 diff -urN postgresql-8.2.1/src/interfaces/libpq/fe-secure.c postgresql-8.2.1-tsnorri/src/interfaces/libpq/fe-secure.c
 --- postgresql-8.2.1/src/interfaces/libpq/fe-secure.c	2006-10-06 20:14:01.000000000 +0300
-+++ postgresql-8.2.1-tsnorri/src/interfaces/libpq/fe-secure.c	2007-02-01 14:35:46.000000000 +0200
++++ postgresql-8.2.1-tsnorri/src/interfaces/libpq/fe-secure.c	2007-02-06 12:37:06.000000000 +0200
 @@ -193,10 +193,10 @@
  }
  
  	/* Begin or continue the actual handshake */
  	return open_client_SSL(conn);
  #else
-@@ -851,6 +865,7 @@
- 	if (r <= 0)
- 	{
- 		int			err = SSL_get_error(conn->ssl, r);
-+        printf ("SSL error: %d\n", err);
- 
- 		switch (err)
- 		{
 diff -urN postgresql-8.2.1/src/interfaces/libpq/libpq-fe.h postgresql-8.2.1-tsnorri/src/interfaces/libpq/libpq-fe.h
 --- postgresql-8.2.1/src/interfaces/libpq/libpq-fe.h	2006-10-04 03:30:13.000000000 +0300
 +++ postgresql-8.2.1-tsnorri/src/interfaces/libpq/libpq-fe.h	2007-01-23 16:36:58.000000000 +0200