Browse Source

Fixed memory leak in case of stopSync : delete Sync messages remaining in the queue before.

IOSAD-21
Edouard Tisserant 5 years ago
parent
commit
b22dee67f1
3 changed files with 30 additions and 5 deletions
  1. +4
    -3
      pEpObjCAdapter/PEPObjCAdapter.m
  2. +4
    -0
      pEpObjCAdapter/PEPQueue.h
  3. +22
    -2
      pEpObjCAdapter/PEPQueue.m

+ 4
- 3
pEpObjCAdapter/PEPObjCAdapter.m View File

@ -385,9 +385,10 @@ static id <PEPSyncDelegate> syncDelegate = nil;
if (syncQueue)
{
// FIXME : memory leak ! unallocate sync message waiting in the queue
[syncQueue kill];
[syncQueue purge:^(id item){
sync_msg_t *msg = [item pointerValue];
free_sync_msg(msg);
}];
[syncThreadJoinCond lockWhenCondition:YES];
[syncThreadJoinCond unlock];


+ 4
- 0
pEpObjCAdapter/PEPQueue.h View File

@ -8,6 +8,8 @@
#import <Foundation/Foundation.h>
typedef void (^deleteOp)(id);
@interface PEPQueue : NSObject
- (void)enqueue:(id)object;
@ -18,6 +20,8 @@
- (void)kill;
- (void)purge:(deleteOp)del;
- (NSUInteger)count;
@end

+ 22
- 2
pEpObjCAdapter/PEPQueue.m View File

@ -100,14 +100,34 @@
- (void)kill
{
_queue = nil;
@synchronized(self) {
_queue = nil;
}
[_cond signal];
}
- (void)purge:(deleteOp)del
{
@synchronized(self) {
id item;
for (item in _queue)
{
del(item);
}
_queue = nil;
}
[_cond signal];
}
- (NSUInteger)count
{
return [_queue count];
NSUInteger res;
@synchronized(self) {
res = [_queue count];
}
return res;
}
- (void)dealloc


Loading…
Cancel
Save