Skip to content

Commit 424a6e6

Browse files
Merge pull request #451 from Countly/fix_post_flutter_tests
mixed: support parallel run, sbs validation
2 parents 40ceae7 + 9a3418d commit 424a6e6

6 files changed

Lines changed: 231 additions & 69 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## XX.XX.XX
2+
* Mitigated a race condition in the request queue that could drop or duplicate requests.
3+
* Mitigated an issue where server config defaults overrode user-provided SDK limits.
4+
* Mitigated an issue where invalid or unknown `sdkBehaviorSettings` keys were persisted.
5+
* Mitigated an issue where listing-filter conflicts cleared keys across unrelated categories.
6+
* Mitigated an issue where consent could be sent twice during initialization.
7+
18
## 26.1.1
29
* Added POST method support for contents.
310
* Added robust resource loading checks before displaying content

Countly.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ - (void)startWithConfig:(CountlyConfig *)config
326326
[self recordIndirectAttribution:config.indirectAttribution];
327327

328328
[CountlyHealthTracker.sharedInstance sendHealthCheck];
329+
330+
CountlyCommon.sharedInstance.hasFinishedInit = YES;
329331
}
330332

331333
- (CountlyConfig *) checkAndFixInternalLimitsConfig:(CountlyConfig *)config

CountlyCommon.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ extern NSString* const kCountlySDKName;
8080
@property (nonatomic, copy) NSString* SDKName;
8181

8282
@property (nonatomic) BOOL hasStarted;
83+
@property (nonatomic) BOOL hasFinishedInit;
8384
@property (nonatomic) BOOL enableDebug;
8485

8586
@property (nonatomic) BOOL shouldIgnoreTrustCheck;

CountlyCommon.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ - (void)resetInstance {
7070
[NSNotificationCenter.defaultCenter removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
7171
#endif
7272
_hasStarted = false;
73+
_hasFinishedInit = false;
7374
_maxKeyLength = kCountlyMaxKeyLength;
7475
_maxValueLength = kCountlyMaxValueSize;
7576
_maxSegmentationValues = kCountlyMaxSegmentationValues;

CountlyConnectionManager.m

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ @interface CountlyConnectionManager ()
1818

1919
@property (nonatomic, strong) NSDate *startTime;
2020
@property (nonatomic, assign) atomic_bool backoff;
21+
@property (nonatomic, assign) atomic_bool isProcessingQueue;
2122
@property (nonatomic, strong) NSMutableDictionary<NSString *, CLYRequestCallback> *internalRequestCallbacks;
2223
@property (nonatomic, strong) NSMutableArray<CLYQueueFlushRunnable> *queueFlushRunnables;
2324
@property (nonatomic) BOOL hasAnyRequestFailed;
@@ -109,6 +110,7 @@ - (instancetype)init
109110
unsentSessionLength = 0.0;
110111
isSessionStarted = NO;
111112
atomic_init(&_backoff, NO);
113+
atomic_init(&_isProcessingQueue, NO);
112114
_internalRequestCallbacks = [NSMutableDictionary dictionary];
113115
_queueFlushRunnables = [NSMutableArray array];
114116
_hasAnyRequestFailed = NO;
@@ -133,6 +135,7 @@ - (void)resetInstance {
133135
[self->_queueFlushRunnables removeAllObjects];
134136
});
135137
_hasAnyRequestFailed = NO;
138+
atomic_store(&_isProcessingQueue, NO);
136139
}
137140

138141
- (void)setHost:(NSString *)host
@@ -194,33 +197,37 @@ - (void)proceedOnQueue
194197
return;
195198
}
196199

197-
if (self.connection)
200+
if (self.connection || atomic_exchange(&_isProcessingQueue, YES))
198201
{
199202
CLY_LOG_D(@"Proceeding on queue is aborted: Already has a request in process!");
200203
return;
201204
}
202-
205+
203206
if (isCrashing)
204207
{
205208
CLY_LOG_D(@"Proceeding on queue is aborted: Application is crashing!");
209+
atomic_store(&_isProcessingQueue, NO);
206210
return;
207211
}
208-
212+
209213
if (self.isTerminating)
210214
{
211215
CLY_LOG_D(@"Proceeding on queue is aborted: Application is terminating!");
216+
atomic_store(&_isProcessingQueue, NO);
212217
return;
213218
}
214-
219+
215220
if (CountlyPersistency.sharedInstance.isQueueBeingModified)
216221
{
217222
CLY_LOG_D(@"Proceeding on queue is aborted: Queue is being modified!");
223+
atomic_store(&_isProcessingQueue, NO);
218224
return;
219225
}
220-
226+
221227
BOOL backoffFlag = atomic_load(&_backoff) ? YES : NO;
222228
if (backoffFlag) {
223229
CLY_LOG_I(@"%s, currently backed off, skipping proceeding the queue", __FUNCTION__);
230+
atomic_store(&_isProcessingQueue, NO);
224231
return;
225232
}
226233

@@ -263,6 +270,7 @@ - (void)proceedOnQueue
263270
// Reset start time and failure flag for future queue processing
264271
self.startTime = nil;
265272
self.hasAnyRequestFailed = NO;
273+
atomic_store(&_isProcessingQueue, NO);
266274
return;
267275
}
268276

@@ -272,17 +280,19 @@ - (void)proceedOnQueue
272280
[CountlyPersistency.sharedInstance removeFromQueue:firstItemInQueue];
273281

274282
[CountlyPersistency.sharedInstance saveToFile];
275-
283+
284+
atomic_store(&_isProcessingQueue, NO);
276285
[self proceedOnQueue];
277-
286+
278287
return;
279288
}
280-
289+
281290

282291
NSString* temporaryDeviceIDQueryString = [NSString stringWithFormat:@"&%@=%@", kCountlyQSKeyDeviceID, CLYTemporaryDeviceID];
283292
if ([firstItemInQueue containsString:temporaryDeviceIDQueryString])
284293
{
285294
CLY_LOG_D(@"Proceeding on queue is aborted: Device ID in request is CLYTemporaryDeviceID!");
295+
atomic_store(&_isProcessingQueue, NO);
286296
return;
287297
}
288298

@@ -360,6 +370,7 @@ - (void)proceedOnQueue
360370
self.connection = [self.URLSession dataTaskWithRequest:request completionHandler:^(NSData * data, NSURLResponse * response, NSError * error)
361371
{
362372
self.connection = nil;
373+
atomic_store(&self->_isProcessingQueue, NO);
363374
NSDate *endTimeRequest = [NSDate date];
364375
long duration = (long)[endTimeRequest timeIntervalSinceDate:startTimeRequest];
365376

0 commit comments

Comments
 (0)