PebbleOS
Loading...
Searching...
No Matches
Data Structures | Enumerations | Functions

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.
 

Detailed Description

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.


Data Structure Documentation

◆ BlobDBSyncSession

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.

Enumeration Type Documentation

◆ BlobDBSyncSessionState

State of a sync session.

Enumerator
BlobDBSyncSessionStateIdle 

No write in flight.

BlobDBSyncSessionStateWaitingForAck 

Waiting for the phone to acknowledge the current write.

◆ BlobDBSyncSessionType

Scope of a sync session.

Enumerator
BlobDBSyncSessionTypeDB 

Whole database, written back with WRITEBACK and ended with SYNC_DONE.

BlobDBSyncSessionTypeRecord 

Single record, written with WRITE.

Function Documentation

◆ blob_db_sync_cancel()

void blob_db_sync_cancel ( BlobDBSyncSession *  session)

Cancel a sync and free the session.

Pending records are synced next time.

Parameters
sessionSession to cancel.

◆ blob_db_sync_db()

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.

Parameters
db_idDatabase to sync.
Return values
S_SUCCESSSync started.
S_NO_ACTION_REQUIREDNo dirty records.
E_BUSYA sync of this database is already in progress.
E_INVALID_ARGUMENTInvalid database.

◆ blob_db_sync_get_session_for_id()

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.

Parameters
db_idDatabase.
Returns
Session, NULL if no sync is in progress.

◆ blob_db_sync_get_session_for_token()

BlobDBSyncSession * blob_db_sync_get_session_for_token ( BlobDBToken  token)

Get the sync session waiting for a response with a given token.

Parameters
tokenToken of the write.
Returns
Session, NULL if none matches.

◆ blob_db_sync_next()

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.

Parameters
sessionSession; may be freed by the call.

◆ blob_db_sync_record()

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.

Parameters
db_idDatabase of the record.
keyKey data.
key_lenLength of key in bytes.
last_updatedModification time of the record.
Return values
S_SUCCESSSync started or deferred to the running session.
E_INVALID_ARGUMENTInvalid database.