Commit Graph
20 Commits
Author SHA1 Message Date
LibretroAdmin 7b0159d5b8 cloud_sync: hand calls and results to the worker without a lock
A blocking driver's calls reach the worker on a many-producer stack and
its results come back on another; the worker parks on an eventcount
when the sync is still open and the queue is empty, and leaves once it
ends. A call queued as the worker leaves either starts a new worker or
is taken by the leaving one. cloud_sync_deinit() waits for the worker
on an eventcount, still bounded by its timeout.

Without pointer atomics the calls run directly, as without threads.

The async test queues a sync from the worker's leaving point.
2026-10-29 22:31:19 +01:00
libretroadmin 0e464bdf41 cloudsync: a blocking driver's calls read settings copied as the sync is pushed
The cloud_sync_capture hook copies the settings a driver's calls read,
on the main thread as the sync's task is pushed, where the task takes
its own copy too. SMB and NFS read the share, the account, the
timeouts and the destructive flag from that copy rather than from the
live settings: their calls run on a worker, read some of them after a
network call returns, and one still blocked past the exit wait would
otherwise read settings the frontend has freed.

cloudsync_async_test checks the hook runs once on the calling thread
and that a driver without one is left alone.
2026-10-05 12:51:48 +02:00
libretroadmin c7f72914a9 cloudsync: a result past the exit wait is the worker's, and polls are paced
cloud_sync_deinit() moves the calls on to a new generation. A call made
before it that is still running when the wait gives up is disposed of by
the worker once it returns - its file closed, nothing handed back - so
its handler never runs for a task that is gone, and a sync begun later
never sees it.

cloud_sync_poll() takes the caller's budget callback and runs the oldest
finished result unconditionally, then more only while the budget allows;
the cloud sync task polls inside its shared I/O window, so a burst of
results is spread over as many runs as the window asks. NULL runs them
all. cloudsync_async_test covers the paced poll and a sync begun while an
abandoned call is still stuck.
2026-10-05 12:20:44 +02:00
libretroadmin 5e968f8b99 cloudsync: blocking drivers run on a worker, results come back by poll
SMB and NFS are flagged CLOUD_SYNC_DRIVER_FLG_BLOCKING: their calls
block on the network until done. With threads, cloud_sync_*() queues
them for one worker per sync, which runs them in call order, and
returns at once; cloud_sync_poll(), called first by the task handler,
runs each completion handler on the handler's own thread. A slow or
unreachable server no longer holds up the thread driving the sync -
the frame loop itself with Threaded Tasks off. Each call is one
allocation with its names copied; the worker leaves once the sync ends
or fails to begin. Without threads the calls are made directly.

On exit, after the task drain, cloud_sync_deinit() drops the calls not
started (closing an upload's file) and waits at most a second for the
one under way, so no driver code runs into the teardown.
samples/tasks/cloudsync/cloudsync_async_test covers ordering, threads,
copying, refusals, worker turnover and the exit path in CI.
2026-10-05 04:38:55 +02:00
Roman Vasilyev a7c4f1e7c1 cloudsync: add NFS backend
Use the built-in NFS client for cloud synchronization, including atomic uploads and non-destructive backups. Enable the backend in regular and Griffin builds so it is available on webOS, iOS, and Android.
2026-10-05 03:39:20 +02:00
LibretroAdmin 3c1b3a5f5e net_http: move the body-framing check out of cloud_sync_driver
cloud_sync_http_body_is_framed lived in network/cloud_sync_driver.c,
which the webdav_options, webdav_reauth and gdrive_backup samples do
not link, so all three failed with an undefined reference once
webdav.c and google_drive.c started calling it (#19631).

The check restates the two tests net_http itself uses to pick the body
framing, so it belongs beside them: it is now net_http_body_is_framed
in libretro-common/net/net_http.c, which every one of those samples
already links. cloud_sync_driver.c/h lose the copy and its includes.

webdav_reauth's stale-nonce test answered the retried GET with a 200
that carried no headers, which the read callback now correctly refuses
as unframed; the test's response gets a Content-Length like a real one.
All three samples build and pass under ASan/UBSan again.
2026-09-26 18:50:15 +02:00
Anthony SchemelandClaude Opus 5.5 891d09385c cloud_sync: refuse unframed download bodies, handle allocation failure (#19631)
net_http fails a transfer that ends before its Content-Length or its
final chunk. A response with neither is delimited by the connection
closing, and net_http documents that it cannot tell a complete body
from one cut off by a dropped connection. The WebDAV and Google Drive
read callbacks accepted such a body as a successful download and wrote
it over the local save. A connection that drops mid-download could
therefore replace a save with a truncated copy, which the next sync
then uploads.

The read callbacks now treat a 2xx response without Content-Length or
"Transfer-Encoding: chunked" as a failed download and leave the local
file alone. The check is shared as cloud_sync_http_body_is_framed and
matches the headers net_http itself uses to pick the body framing.

Also NULL-check allocations that were used unchecked: the WebDAV
digest-auth chain (HA1, HA2, response, header), webdav_delete's
callback state, and the Google Drive context in
gdrive_begin_with_token. Each now fails the operation instead of
writing through NULL.

Tested on Linux: full build; touched files also compile with
C89_BUILD=1 without warnings. A small program linked against the
built cloud_sync_driver.o returned true for Content-Length and for
chunked (any case), false for no framing, "gzip, chunked" and a NULL
list. Not tested against a live WebDAV or Google Drive server.

Co-authored-by: Claude Opus 5.5 <[email protected]>
2026-09-26 17:18:17 +02:00
Russell Parks c7bf80fb72 S3 Implementation 2026-03-10 22:00:52 -05:00
Eric Warmenhoven 421ba9efe3 smb cloud sync driver 2026-02-18 15:37:11 -05:00
Eric Warmenhoven 6cf7502a73 google drive cloud sync driver 2026-02-17 23:09:35 -05:00
libretroadmin ae2465f0db Variable name changes 2025-07-17 23:41:27 +02:00
Davide Andreoli 2f1ae73dd4 feat: added iCloud Drive Cloud Sync 2025-05-12 08:54:06 -04:00
LibretroAdmin 0f5a990141 Cleanups 2025-02-11 10:28:16 +01:00
Alex KiralyandWindowsDEV 0b05b1e3f4 Fix CloudSync on Windows, enable by default (#16475)
* Make paths portable for CloudSync when building manifest

* Enable CloudSync on Windows builds

* Fix "fetech server file" - Forgot to commit this, oops!

* Fix definition conflict with gzguts.h

* "Enable Cloud Sync for Windows UWP builds"

---------

Co-authored-by: WindowsDEV <[email protected]>
2024-11-25 09:47:27 -08:00
libretroadmin 82e4504968 Revert "(pt. 2) static variables are initialized to '0' automatically as per C rules"
This reverts commit 47410df7a3.
2024-11-19 03:03:05 +01:00
libretroadmin 47410df7a3 (pt. 2) static variables are initialized to '0' automatically as per C rules 2024-11-18 15:59:46 +01:00
Eric Warmenhoven a26f6f6b45 webdav: fixes for reauth and parallelism (#17132) 2024-10-29 12:03:46 -07:00
libretroadmin afc9cb509a CXX_BUILDFIX buildfixes 2024-07-20 19:42:45 +02:00
Eric Warmenhoven 63799385fc iCloud cloud sync driver (#16794) 2024-07-18 22:02:52 -07:00
Eric Warmenhoven 893b0d142e Cloud Sync (#15548)
* cloud sync - algorithm and abstract cloud storage API

* WebDAV cloud sync driver, and associated net_http improvements

* Cloud sync settings menu
2023-08-04 09:20:50 +02:00