Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
z-push
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Björn Fischer
z-push
Commits
967a0c36
Commit
967a0c36
authored
Sep 09, 2015
by
Sebastian Kummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZP-697 Honour global window size. Released under the Affero GNU General
Public License (AGPL) version 3.
parent
0dbd04af
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
9 deletions
+31
-9
synccollections.php
src/lib/core/synccollections.php
+2
-2
sync.php
src/lib/request/sync.php
+29
-7
No files found.
src/lib/core/synccollections.php
View file @
967a0c36
...
...
@@ -334,11 +334,11 @@ class SyncCollections implements Iterator {
* in a case of a heartbeat and/or partial sync
*
* @access public
* @return int/boolean returns
false
if not set or not available
* @return int/boolean returns
512 (max)
if not set or not available
*/
public
function
GetGlobalWindowSize
()
{
if
(
!
isset
(
$this
->
globalWindowSize
))
return
false
;
return
512
;
return
$this
->
globalWindowSize
;
}
...
...
src/lib/request/sync.php
View file @
967a0c36
...
...
@@ -61,6 +61,7 @@ class Sync extends RequestProcessor {
$status
=
SYNC_STATUS_SUCCESS
;
$wbxmlproblem
=
false
;
$emptysync
=
false
;
$globallyExportedItems
=
0
;
// check if the hierarchySync was fully completed
...
...
@@ -522,6 +523,7 @@ class Sync extends RequestProcessor {
if
(
self
::
$decoder
->
getElementStartTag
(
SYNC_WINDOWSIZE
))
{
$sc
->
SetGlobalWindowSize
(
self
::
$decoder
->
getElementContent
());
ZLog
::
Write
(
LOGLEVEL_DEBUG
,
"Sync(): Global WindowSize requested: "
.
$sc
->
GetGlobalWindowSize
());
if
(
!
self
::
$decoder
->
getElementEndTag
())
// SYNC_WINDOWSIZE
return
false
;
}
...
...
@@ -570,10 +572,6 @@ class Sync extends RequestProcessor {
// manually set getchanges parameter for this collection
$sc
->
AddParameter
(
$spa
,
"getchanges"
,
true
);
// set new global windowsize without marking the SPA as changed
if
(
$sc
->
GetGlobalWindowSize
())
$spa
->
SetWindowSize
(
$sc
->
GetGlobalWindowSize
(),
false
);
// announce WindowSize to DeviceManager
self
::
$deviceManager
->
SetWindowSize
(
$folderid
,
$spa
->
GetWindowSize
());
}
...
...
@@ -752,12 +750,26 @@ class Sync extends RequestProcessor {
continue
;
}
// Get a new sync key to output to the client if any changes have been send
or will are available
// Get a new sync key to output to the client if any changes have been send
by the mobile or a new synckey is to be sent
if
(
!
empty
(
$actiondata
[
"modifyids"
])
||
!
empty
(
$actiondata
[
"clientids"
])
||
!
empty
(
$actiondata
[
"removeids"
])
||
$changecount
>
0
||
(
!
$spa
->
HasSyncKey
()
&&
$status
==
SYNC_STATUS_SUCCESS
))
(
!
$spa
->
HasSyncKey
()
&&
$status
==
SYNC_STATUS_SUCCESS
))
{
$spa
->
SetNewSyncKey
(
self
::
$deviceManager
->
GetStateManager
()
->
GetNewSyncKey
(
$spa
->
GetSyncKey
()));
}
// get a new synckey only if we did not reach the global limit yet
else
{
// when reaching the global limit for changes of all collections, stop processing other collections (ZP-697)
if
(
$sc
->
GetGlobalWindowSize
()
<=
$globallyExportedItems
)
{
ZLog
::
Write
(
LOGLEVEL_DEBUG
,
"Global WindowSize for amount of exported changes reached, omitting output for collection."
);
continue
;
}
// get a new synckey if there are changes are we did not reach the limit yet
if
(
$changecount
>
0
)
{
$spa
->
SetNewSyncKey
(
self
::
$deviceManager
->
GetStateManager
()
->
GetNewSyncKey
(
$spa
->
GetSyncKey
()));
}
}
self
::
$encoder
->
startTag
(
SYNC_FOLDER
);
...
...
@@ -891,7 +903,14 @@ class Sync extends RequestProcessor {
if
(
$sc
->
GetParameter
(
$spa
,
"getchanges"
)
&&
$spa
->
HasFolderId
()
&&
$spa
->
HasContentClass
()
&&
$spa
->
HasSyncKey
())
{
$windowSize
=
self
::
$deviceManager
->
GetWindowSize
(
$spa
->
GetFolderId
(),
$spa
->
GetContentClass
(),
$spa
->
GetUuid
(),
$spa
->
GetUuidCounter
(),
$changecount
);
// limit windowSize to the max available limit of the global window size left
$globallyAvailable
=
$sc
->
GetGlobalWindowSize
()
-
$globallyExportedItems
;
if
(
$changecount
>
$globallyAvailable
)
{
ZLog
::
Write
(
LOGLEVEL_DEBUG
,
sprintf
(
"HandleSync(): Limit window size to %d as the global window size limit will be reached"
,
$globallyAvailable
));
$windowSize
=
$globallyAvailable
;
}
// send <MoreAvailable/> if there are more changes than fit in the folder windowsize
if
(
$changecount
>
$windowSize
)
{
self
::
$encoder
->
startTag
(
SYNC_MOREAVAILABLE
,
false
,
true
);
}
...
...
@@ -911,6 +930,8 @@ class Sync extends RequestProcessor {
if
(
!
is_array
(
$progress
))
break
;
$n
++
;
if
(
$n
%
10
==
0
)
self
::
$topCollector
->
AnnounceInformation
(
sprintf
(
"Streamed data of %d objects out of %d"
,
$n
,
((
$changecount
>
$windowSize
)
?
$windowSize
:
$changecount
)));
}
catch
(
SyncObjectBrokenException
$mbe
)
{
$brokenSO
=
$mbe
->
GetSyncObject
();
...
...
@@ -949,6 +970,7 @@ class Sync extends RequestProcessor {
self
::
$encoder
->
endTag
();
self
::
$topCollector
->
AnnounceInformation
(
sprintf
(
"Outgoing %d objects%s"
,
$n
,
(
$n
>=
$windowSize
)
?
" of "
.
$changecount
:
""
),
true
);
$globallyExportedItems
+=
$n
;
// update folder status, if there is something set
if
(
$spa
->
GetFolderSyncRemaining
()
&&
$changecount
>
0
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment