|
PebbleOS
|
Write-back of dirty records to the phone. More...
Data Structures | |
| struct | BlobDBSyncSession |
| Sync session, writing the dirty records of a database back to the phone one at a time. More... | |
Enumerations | |
| enum | BlobDBSyncSessionState { BlobDBSyncSessionStateIdle = 0 , BlobDBSyncSessionStateWaitingForAck = 1 } |
| State of a sync session. More... | |
| enum | BlobDBSyncSessionType { BlobDBSyncSessionTypeDB , BlobDBSyncSessionTypeRecord } |
| Scope of a sync session. More... | |
Functions | |
| status_t | blob_db_sync_db (BlobDBId db_id) |
| Start writing back the dirty records of a database. | |
| status_t | blob_db_sync_record (BlobDBId db_id, const void *key, int key_len, time_t last_updated) |
| Start writing a single record to the phone. | |
| BlobDBSyncSession * | blob_db_sync_get_session_for_id (BlobDBId db_id) |
| Get the whole-database sync session of a database. | |
| BlobDBSyncSession * | blob_db_sync_get_session_for_token (BlobDBToken token) |
| Get the sync session waiting for a response with a given token. | |
| void | blob_db_sync_next (BlobDBSyncSession *session) |
| Mark the current record as synced and send the next one. | |
| void | blob_db_sync_cancel (BlobDBSyncSession *session) |
| Cancel a sync and free the session. | |
Write-back of dirty records to the phone.
Records are sent one at a time over the BlobDB sync endpoint; each acknowledgement marks the record as synced and sends the next one. A write without answer is retried every 30 seconds and the session is abandoned after 5 minutes.
| struct BlobDBSyncSession |
Sync session, writing the dirty records of a database back to the phone one at a time.
| Data Fields | ||
|---|---|---|
| RegularTimerInfo | abandon_timer | Cancels the session after repeated timeouts. |
| BlobDBToken | current_token | Token of the write in flight. |
| BlobDBId | db_id | Database being synced. |
| BlobDBDirtyItem * | dirty_list | Records left to sync; the head is the one in flight. |
| ListNode | node | List node. |
| uint32_t | session_id |
Unique id, never reused. Deferred timer callbacks carry this instead of a session pointer so they can detect a session that has already been freed. |
| BlobDBSyncSessionType | session_type | Session scope. |
| BlobDBSyncSessionState | state | Session state. |
| RegularTimerInfo | timeout_timer | Retries the current write when the phone does not answer in time. |
| void blob_db_sync_cancel | ( | BlobDBSyncSession * | session | ) |
Cancel a sync and free the session.
Pending records are synced next time.
| session | Session to cancel. |
| status_t blob_db_sync_db | ( | BlobDBId | db_id | ) |
Start writing back the dirty records of a database.
Sends SYNC_DONE immediately when there is nothing to sync.
| db_id | Database to sync. |
| S_SUCCESS | Sync started. |
| S_NO_ACTION_REQUIRED | No dirty records. |
| E_BUSY | A sync of this database is already in progress. |
| E_INVALID_ARGUMENT | Invalid database. |
| BlobDBSyncSession * blob_db_sync_get_session_for_id | ( | BlobDBId | db_id | ) |
Get the whole-database sync session of a database.
Single-record sessions are not returned.
| db_id | Database. |
| BlobDBSyncSession * blob_db_sync_get_session_for_token | ( | BlobDBToken | token | ) |
Get the sync session waiting for a response with a given token.
| token | Token of the write. |
| void blob_db_sync_next | ( | BlobDBSyncSession * | session | ) |
Mark the current record as synced and send the next one.
When the list is exhausted, picks up records that became dirty meanwhile, or ends the session and frees it.
| session | Session; may be freed by the call. |
| status_t blob_db_sync_record | ( | BlobDBId | db_id, |
| const void * | key, | ||
| int | key_len, | ||
| time_t | last_updated | ||
| ) |
Start writing a single record to the phone.
If a whole-database sync is in progress, the record is picked up by it instead.
| db_id | Database of the record. |
| key | Key data. |
| key_len | Length of key in bytes. |
| last_updated | Modification time of the record. |
| S_SUCCESS | Sync started or deferred to the running session. |
| E_INVALID_ARGUMENT | Invalid database. |