Author: rfm
Date: Tue Oct 18 10:32:05 2016
New Revision: 40152
URL: http://svn.gna.org/viewcvs/gnustep?rev=40152&view=rev
Log:
Don't allow pool clients to be set as database notification observers
Modified:
libs/sqlclient/trunk/ChangeLog
libs/sqlclient/trunk/SQLClient.h
libs/sqlclient/trunk/SQLClient.m
Modified: libs/sqlclient/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/sqlclient/trunk/ChangeLog?rev=40152&r1=40151&r2=40152&view=diff
==============================================================================
--- libs/sqlclient/trunk/ChangeLog (original)
+++ libs/sqlclient/trunk/ChangeLog Tue Oct 18 10:32:05 2016
@@ -1,3 +1,11 @@
+2016-10-18 Richard Frith-Macdonald <[email protected]>
+
+ * SQLClient.h:
+ * SQLClient.m:
+ Make -addObserver:selector:name: raise if applied to a client in a
+ pool. Improve documentation to make it clear that pool clients
+ can't be used as observers of database notifications.
+
2016-06-23 Richard Frith-Macdonald <[email protected]>
* SQLClient.m: Fixup to use case sensitive notification names.
Modified: libs/sqlclient/trunk/SQLClient.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/sqlclient/trunk/SQLClient.h?rev=40152&r1=40151&r2=40152&view=diff
==============================================================================
--- libs/sqlclient/trunk/SQLClient.h (original)
+++ libs/sqlclient/trunk/SQLClient.h Tue Oct 18 10:32:05 2016
@@ -1291,7 +1291,13 @@
* occur inside a transaction is the -begin and -commit statements
* are used. For this reason, observing code may want to use the
* -lockBeforeDate: -isInTransaction and -unlock methods to ensure
- * that they don't interfere with ongoing transactions.
+ * that they don't interfere with ongoing transactions.<br />
+ * For observation of notifications to be immediately effective, the
+ * instance must be connected to the database (and remain connected),
+ * so you can't call this method on a client from a pool, and you should
+ * make sure that you don't close the client connection (or if you do,
+ * that you make sure to re-open it in order to start receiving
+ * notifications again).
*/
- (void) addObserver: (id)anObserver
selector: (SEL)aSelector
@@ -1578,6 +1584,13 @@
* method which would be required to be followed up by another message to
* the same client.
* </p>
+ * <p>NB. Any client provided from a pool should be returned to the
+ * pool as soon as reasonably possible (and if left idle will have its
+ * connection to the server closed anyway) so that it can be used by
+ * other threads. If you want a permenantly open database connection
+ * you should use a normal SQLClient instance, not one from a pool.
+ * You must not call -addObserver:selector:name: on a client from a pool.
+ * </p>
*/
@interface SQLClientPool : NSObject
{
@@ -1669,7 +1682,12 @@
* If isLocal is YES, this method provides a client which will not be
* used elsewhere in the same thread until/unless the calling code
* returns it to the pool. Otherwise (isLocal is NO), the client may
- * be used by other code in the same thread.
+ * be used by other code in the same thread.<br />
+ * NB. Any client provided using this method should be returned to the
+ * pool as soon as reasonably possible (and if left idle will have its
+ * connection to the server closed anyway) so that it can be used by
+ * other threads. If you want a permenantly open database connection
+ * you should use a normal SQLClient instance, not one from a pool.
*/
- (SQLClient*) provideClientBeforeDate: (NSDate*)when exclusive: (BOOL)isLocal;
Modified: libs/sqlclient/trunk/SQLClient.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/sqlclient/trunk/SQLClient.m?rev=40152&r1=40151&r2=40152&view=diff
==============================================================================
--- libs/sqlclient/trunk/SQLClient.m (original)
+++ libs/sqlclient/trunk/SQLClient.m Tue Oct 18 10:32:05 2016
@@ -3054,7 +3054,7 @@
}
else
{
- /* Not really an asynchronous query becuse we wait until it's
+ /* Not really an asynchronous query because we wait until it's
* done in order to have a result we can return.
*/
[self performSelectorOnMainThread: @selector(_populateCache:)
@@ -3867,6 +3867,11 @@
[NSException raise: NSInvalidArgumentException
format: @"Attempt to add nil observer to SQL client"];
}
+ if (nil != _pool)
+ {
+ [NSException raise: NSInvalidArgumentException
+ format: @"Attempt to use pool client as observer"];
+ }
name = validName(name);
[lock lock];
NS_DURING
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs