Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OneDrive Client Version v2.5.0-alpha-4 + @JC-comp #2519: Replace polling monitor loop with blocking wait #2582

Closed
wants to merge 78 commits into from

Conversation

abraunegg
Copy link
Owner

@abraunegg abraunegg commented Jan 7, 2024

Summary

This is an implementation that resolves #2518

Changes

  • Replace polling monitor loop with blocking wait
  • Check inotify events in separate threads and send signals to main thread when changes are available
  • Add blocking wait support for webhooks
  • Only handle changes from /delta when webhook events are received
  • Handle all inotify events and never discard them at any time to prevent missing local changes

How Has This Been Tested?

  • build and run in monitor loop
  • test local change handling trigger: create/delete/move local file/folder
  • test remote sync trigger: wait for next monitor_interval
  • test shutdown capability: monitor_max_loop set to 1 and 2
  • test integration:
    • sync mode
    • local first
    • upload only
    • download only
  • test stability: run 6 300-sec-interval monitor loop

What is still missing?

  • Checking if the interrupt triggered at src/monitor.d is mandatory (does not affect functionality)

Effect
Remove the following inotify polling and sync checking, sleep every second

clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=0}, 0x7ffda2aa2490) = 0
poll([{fd=6, events=POLLIN}], 1, 0)     = 0 (Timeout)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=0}, 0x7ffda2aa2490) = 0
poll([{fd=6, events=POLLIN}], 1, 0)     = 0 (Timeout)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=0}, 0x7ffda2aa2490) = 0
poll([{fd=6, events=POLLIN}], 1, 0)     = 0 (Timeout)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=1, tv_nsec=0}, 0x7ffda2aa2490) = 0
poll([{fd=6, events=POLLIN}], 1, 0)     = 0 (Timeout)
....

abraunegg and others added 30 commits October 19, 2023 05:31
commit 1eff2d7
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Wed Oct 18 19:15:27 2023 +1100

    Update PR

    * Add  --source-directory 'path/as/source/' --destination-directory 'path/as/destination' functionality

commit ad3ddee
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Wed Oct 18 17:32:24 2023 +1100

    Update PR

    * Add --create-directory
    * Add --remove-directory

commit 7dfe6b6
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Wed Oct 18 12:27:03 2023 +1100

    Update PR

    * Update PR

commit 75c071e
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Wed Oct 18 10:12:05 2023 +1100

    Update PR

    * Update PR

commit 6db484c
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Mon Oct 16 17:01:25 2023 +1100

    Update PR

    * Update PR

commit d893ea5
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Wed Oct 11 10:43:50 2023 +1100

    Update PR

    * Update PR

commit 82bd593
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Wed Oct 11 09:14:17 2023 +1100

    Update PR

    * Validate and document --auth-files operation

commit c551203
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Wed Oct 11 05:48:22 2023 +1100

    Update PR

    * Add --create-share-link

commit fbf6399
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Tue Oct 10 18:39:21 2023 +1100

    Update PR

    * Update PR

commit 72a4680
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Tue Oct 10 17:43:15 2023 +1100

    Update PR

    * Add --get-file-link
    * Add --modified-by

commit 0d3fc3e
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Tue Oct 10 14:28:10 2023 +1100

    Add --display-sync-status

    * Add --display-sync-status

commit 1f183ca
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Mon Oct 9 08:18:13 2023 +1100

    Update PR

    * Update PR with doc updates

commit b0628d7
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Sun Oct 8 10:52:52 2023 +1100

    Update PR

    * Update PR

commit 7e3df95
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Sat Oct 7 05:31:26 2023 +1100

    Update PR

    * Update PR

commit c69f2ab
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Sat Oct 7 05:28:28 2023 +1100

    Update PR

    * Update PR

commit ea1ca33
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Fri Oct 6 14:57:51 2023 +1100

    Update PR

    * Update PR

commit 1503f96
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Fri Oct 6 09:19:04 2023 +1100

    Update PR

    * Update PR

commit 5127464
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Fri Oct 6 06:48:20 2023 +1100

    Change when the integrity check is performed

    * Change when the integrity check is performed

commit c7cc45d
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Thu Oct 5 19:40:05 2023 +1100

    Update maxInotifyWatches location

    * Update maxInotifyWatches location

commit c44ad96
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Thu Oct 5 17:41:31 2023 +1100

    Update main.d

    * Fix --version segfault

commit 51f0ffc
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Thu Oct 5 17:24:30 2023 +1100

    Uplift to v2.5.0-alpha-2

    * Uplift to v2.5.0-alpha-2

commit cbe3e6e
Author: abraunegg <alex.braunegg@gmail.com>
Date:   Thu Oct 5 17:17:26 2023 +1100

    Clean up before onedrive-v2.5.0-alpha-2

    * Clean up before onedrive-v2.5.0-alpha-2
* Uplift to v2.5.0-alpha-3
* Add webhook functionality back in
* Fix that the '.' were not being printed in --verbose mode for fetching the /delta response
* Update webhook feature with #2516 changes
* Add documentation notes for webhooks
* Fix variable naming
* --download-only and --local-first cannot be used together
* Fix onedrive -s --download-only
* Fix onedrive -s --download-only --local-first
* Add a check when using --download-only to test if the file already exists locally, and if it does, has the local file been modified since the file was last downloaded. If it has, then rename the existing file to preserve it to prevent local data loss
* Implement --display-quota
* Add missing curlEngine.http.clearRequestHeaders(); from 'patch' and 'post'
* Cherry pick 5a4a351

Fix by @JC-comp
* Fix curl reusing socket
* Update podman documentation
* Update doc
* Wait for all parallel jobs that depend on the database to complete - added from f86c4b9
* Add debug output to determine DB access threadsafe value
* Simplify existing shutdown cleanup before #2519 is merged
* Update doc, add getenforce check validation
* Update exit scope handling, ensure that oneDriveApiInstance is shutdown otherwise memory leak occurs on exit

PRECHANGE:

==442773== LEAK SUMMARY:
==442773==    definitely lost: 0 bytes in 0 blocks
==442773==    indirectly lost: 0 bytes in 0 blocks
==442773==      possibly lost: 32 bytes in 1 blocks
==442773==    still reachable: 175,810 bytes in 13 blocks
==442773==         suppressed: 0 bytes in 0 blocks

POSTCHANGE:

==450812== LEAK SUMMARY:
==450812==    definitely lost: 0 bytes in 0 blocks
==450812==    indirectly lost: 0 bytes in 0 blocks
==450812==      possibly lost: 32 bytes in 1 blocks
==450812==    still reachable: 153,856 bytes in 5 blocks
==450812==         suppressed: 0 bytes in 0 blocks
* Fix exit coredump when using -s -v
Update --display-quota output to:

Deleted:   8.19 GB (8793627814 bytes)
Remaining: 25580.69 GB (27467060611614 bytes)
State:     normal
Total:     25600.00 GB (27487790694400 bytes)
Used:      11.12 GB (11936454972 bytes)
* Fix memory leak on exit when using webhooks
* When --syncdir is being used, and no initial config file exists, write the --syncdir value to a new default configuration file, so that when the client is run again, the --syncdir value is used. If an existing config file is present, update the sync_dir config value that was passed in, but only if it is different to the existing set value
* Update PR to add a test for entrypoint.sh to exist, to assist with Docker first run scenario
* Update Podman and Docker documentation
* Update doc
* Update doc
* Update doc
* Add 'Using 'Client Side Filtering' rules to determine what should be synced with Microsoft OneDrive'
* Add TOC link
* Add note regarding Client Side Filtering
* Update usage docs
* Update function comments
* Define a better function and use for checking for HTML URL encoded items in API response JSON elements
* Update doc
* Add back in missing note when application is authorised
* Fix up large file handling output
* Fix calculation error for upload fragments
* Catch an error when the file being uploaded disappears during session upload
* Update doc
* Update doc
* Comment updates
* Remove CurlOption.ssl_verifypeer configuration which was added when developing the multi-threaded transfer handling and OpenSSL was causing issues due to insufficient file handles to open the read of the CA Certificate. If the SSL CA Certificate cannot be read, we should hard exit.
* Add JC-comp #2519 changes to 'alpha-4' minus the changes to 'sync.d' and 'util.d' as these are irrelevant
* Add missing log output for new file adds
@abraunegg
Copy link
Owner Author

@cholzer79 , @Lyncredible

Given the current maturity of 'alpha-4' - are you potentially able to test this specific PR which has changes specifically impacting the current 'WebHooks' feature?

It would be great if you are able to test this and provide some feedback based on using Webhooks with this PR.

@abraunegg abraunegg changed the title Onedrive v2.5.0 alpha 4 add jc 2519v2 OneDrive Client Version v2.5.0-alpha-4 + JC-comp #2519: Replace polling monitor loop with blocking wait Jan 8, 2024
@abraunegg abraunegg changed the title OneDrive Client Version v2.5.0-alpha-4 + JC-comp #2519: Replace polling monitor loop with blocking wait OneDrive Client Version v2.5.0-alpha-4 + @JC-comp #2519: Replace polling monitor loop with blocking wait Jan 8, 2024
* Use variable as set
@Lyncredible
Copy link
Contributor

@abraunegg Sorry but I am quite busy in Jan. Will give it a try when I find some free time but no promises...

@abraunegg
Copy link
Owner Author

abraunegg commented Jan 13, 2024

@Lyncredible

@abraunegg Sorry but I am quite busy in Jan. Will give it a try when I find some free time but no promises...

When you do get to review, please review 'alpha-5' as I am going to close off this PR.

The 'alpha-5' PR is: #2584

@abraunegg abraunegg closed this Jan 13, 2024
@abraunegg
Copy link
Owner Author

Typo: The 'alpha-5' PR is: #2584

@abraunegg abraunegg deleted the onedrive-v2.5.0-alpha-4-add-jc-2519v2 branch January 19, 2024 18:10
@abraunegg
Copy link
Owner Author

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Repository owner locked and limited conversation to collaborators Jan 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Add support for local full scan separation and blocking loop in monitor mode
4 participants