Author: rfm
Date: Wed Nov 26 09:59:50 2014
New Revision: 38202
URL: http://svn.gna.org/viewcvs/gnustep?rev=38202&view=rev
Log:
thread-safety tweak
Modified:
libs/ec/trunk/ChangeLog
libs/ec/trunk/EcProcess.m
Modified: libs/ec/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/ChangeLog?rev=38202&r1=38201&r2=38202&view=diff
==============================================================================
--- libs/ec/trunk/ChangeLog (original)
+++ libs/ec/trunk/ChangeLog Wed Nov 26 09:59:50 2014
@@ -1,3 +1,8 @@
+2014-11-26 Richard Frith-Macdonald <[email protected]>
+
+ * EcProcess.m: Make -cmdLastIP, -cmdLastOP (and their setters)
+ thread-safe.
+
2014-11-02 Richard Frith-Macdonald <[email protected]>
* EcProcess.h:
Modified: libs/ec/trunk/EcProcess.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcProcess.m?rev=38202&r1=38201&r2=38202&view=diff
==============================================================================
--- libs/ec/trunk/EcProcess.m (original)
+++ libs/ec/trunk/EcProcess.m Wed Nov 26 09:59:50 2014
@@ -131,9 +131,9 @@
static NSString *cmdDebugName = nil;
static NSMutableDictionary *cmdLogMap = nil;
-static NSDate *started = nil; /* Time object was created. */
-static NSDate *lastIP = nil; /* Time of last input to object. */
-static NSDate *lastOP = nil; /* Time of last output by object. */
+static NSDate *started = nil; /* Time object was created. */
+static NSTimeInterval lastIP = 0.0; /* Time of last input to object. */
+static NSTimeInterval lastOP = 0.0; /* Time of last output by object. */
static Class cDateClass = 0;
static Class dateClass = 0;
@@ -1021,8 +1021,6 @@
DESTROY(errorLogger);
DESTROY(homeDir);
DESTROY(hostName);
- DESTROY(lastIP);
- DESTROY(lastOP);
DESTROY(noNetConfig);
DESTROY(replyBuffer);
DESTROY(servers);
@@ -1363,12 +1361,20 @@
- (NSDate*) cmdLastIP
{
- return lastIP;
+ if (0.0 == lastIP)
+ {
+ return nil;
+ }
+ return [dateClass dateWithTimeIntervalSinceReferenceDate: lastIP];
}
- (NSDate*) cmdLastOP
{
- return lastOP;
+ if (0.0 == lastOP)
+ {
+ return nil;
+ }
+ return [dateClass dateWithTimeIntervalSinceReferenceDate: lastOP];
}
- (void) cmdLogEnd: (NSString*)name
@@ -2396,20 +2402,26 @@
- (void) ecHadIP: (NSDate*)when
{
- if (when == nil)
- {
- when = [dateClass date];
- }
- ASSIGN(lastIP, when);
+ if (nil == when)
+ {
+ lastIP = [dateClass timeIntervalSinceReferenceDate];
+ }
+ else
+ {
+ lastIP = [when timeIntervalSinceReferenceDate];
+ }
}
- (void) ecHadOP: (NSDate*)when
{
- if (when == nil)
- {
- when = [dateClass date];
- }
- ASSIGN(lastOP, when);
+ if (nil == when)
+ {
+ lastOP = [dateClass timeIntervalSinceReferenceDate];
+ }
+ else
+ {
+ lastOP = [when timeIntervalSinceReferenceDate];
+ }
}
- (NSUInteger) ecNotLeaked
@@ -3340,11 +3352,11 @@
{
[self cmdPrintf: @"\n%@ on %@ running since %@\n",
cmdLogName(), ecHostName(), [self ecStarted]];
- if ([self cmdLastIP] != nil)
+ if (lastIP > 0.0)
{
[self cmdPrintf: @"Last IP at %@\n", [self cmdLastIP]];
}
- if ([self cmdLastOP] != nil)
+ if (lastOP > 0.0)
{
[self cmdPrintf: @"Last OP at %@\n", [self cmdLastOP]];
}
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs