(fix) handle EAS termination when SOGo is being shutdown (fixes #3604)

Conflicts:

	ActiveSync/SOGoActiveSyncDispatcher.m
This commit is contained in:
Ludovic Marcotte
2016-03-29 10:32:10 -04:00
parent 5a2676f91b
commit 44d8b63136
3 changed files with 22 additions and 3 deletions

View File

@@ -1905,6 +1905,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// We enter our loop detection change
for (i = 0; i < (heartbeatInterval/internalInterval); i++)
{
if (shouldTerminate)
break;
s = [NSMutableString string];
for (j = 0; j < [allCollections count]; j++)
@@ -1944,7 +1947,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{
total_sleep = 0;
while (total_sleep < internalInterval)
while (!shouldTerminate && total_sleep < internalInterval)
{
// We check if we must break the current synchronization since an other Sync
// has just arrived.

View File

@@ -37,6 +37,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@class NSURL;
@class NSNumber;
static volatile BOOL shouldTerminate = NO;
@interface SOGoActiveSyncDispatcher : NSObject
{
NSURL *folderTableURL;
@@ -44,7 +46,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
id context;
NSNumber *syncRequest;
BOOL debugOn;
}

View File

@@ -52,6 +52,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#import <NGObjWeb/WODirectAction.h>
#import <NGObjWeb/WORequest.h>
#import <NGObjWeb/WOResponse.h>
#import <NGObjWeb/WOCoreApplication.h>
#import <NGCards/iCalCalendar.h>
#import <NGCards/iCalEntityObject.h>
@@ -144,6 +145,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <openssl/x509.h>
#endif
void handle_terminate(int signum)
{
NSLog(@"Forcing termination of EAS loop.");
shouldTerminate = YES;
[[WOCoreApplication application] terminateAfterTimeInterval: 1];
}
@interface SOGoActiveSyncDispatcher (Sync)
- (NSMutableDictionary *) _folderMetadataForKey: (NSString *) theFolderKey;
@@ -161,6 +169,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
folderTableURL = nil;
imapFolderGUIDS = nil;
syncRequest = nil;
shouldTerminate = NO;
signal(SIGTERM, handle_terminate);
return self;
}
@@ -2098,6 +2110,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// We enter our loop detection change
for (i = 0; i < (heartbeatInterval/internalInterval); i++)
{
if (shouldTerminate)
break;
pool = [[NSAutoreleasePool alloc] init];
for (j = 0; j < [allFoldersID count]; j++)
{
@@ -2135,7 +2150,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{
total_sleep = 0;
while (total_sleep < internalInterval)
while (!shouldTerminate && total_sleep < internalInterval)
{
// We check if we must break the current ping request since an other ping request
// has just arrived.