Author: rfm
Date: Wed Oct 19 14:38:02 2016
New Revision: 40162
URL: http://svn.gna.org/viewcvs/gnustep?rev=40162&view=rev
Log:
Fix for thread safety issue spotted by Wolfgang.
Modified:
libs/sqlclient/trunk/ChangeLog
libs/sqlclient/trunk/Postgres.m
Modified: libs/sqlclient/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/sqlclient/trunk/ChangeLog?rev=40162&r1=40161&r2=40162&view=diff
==============================================================================
--- libs/sqlclient/trunk/ChangeLog (original)
+++ libs/sqlclient/trunk/ChangeLog Wed Oct 19 14:38:02 2016
@@ -1,3 +1,11 @@
+2016-10-19 Richard Frith-Macdonald <[email protected]>
+
+ * Postgres.m: Wolfgang spotted that the asynchronous notification
+ code is not thread safe ... we must not have one thread handle a
+ notification at the same time that another is trying to use the
+ database connectionto execute a query/statement.
+ Use the client's lock to prevent that from happening.
+
2016-10-18 Richard Frith-Macdonald <[email protected]>
* SQLClient.h:
Modified: libs/sqlclient/trunk/Postgres.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/sqlclient/trunk/Postgres.m?rev=40162&r1=40161&r2=40162&view=diff
==============================================================================
--- libs/sqlclient/trunk/Postgres.m (original)
+++ libs/sqlclient/trunk/Postgres.m Wed Oct 19 14:38:02 2016
@@ -563,6 +563,8 @@
[nq enqueueNotification: n postingStyle: NSPostASAP];
}
+/* This method must only be called when the receiver is locked.
+ */
- (void) _checkNotifications: (BOOL)async
{
PGnotify *notify;
@@ -1709,11 +1711,16 @@
extra: (void*)extra
forMode: (NSString*)mode
{
+ /* Ensure that the receiver is locked so that no other thread can
+ * be using the database connection while we use it.
+ */
+ [lock lock];
if (0 != connection)
{
PQconsumeInput(connection);
[self _checkNotifications: YES];
}
+ [lock unlock];
}
@end
#endif
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs