Changeset 4266

Show
Ignore:
Timestamp:
08/21/08 11:25:06 (3 months ago)
Author:
martin
Message:

added sqlite busy handler: retries on locking conflicts

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/libstrongswan/plugins/sqlite/sqlite_database.c

    r4193 r4266  
    1919 
    2020#include <sqlite3.h> 
     21#include <unistd.h> 
    2122#include <library.h> 
    2223#include <debug.h> 
     
    291292 
    292293/** 
     294 * Busy handler implementation 
     295 */ 
     296static int busy_handler(private_sqlite_database_t *this, int count) 
     297{ 
     298    /* add an sleep, exponentially longer on every try */ 
     299    usleep(count * count * 1000); 
     300    /* always retry */ 
     301    return 1; 
     302} 
     303 
     304/** 
    293305 * Implementation of database_t.destroy 
    294306 */ 
     
    334346    } 
    335347     
     348    sqlite3_busy_handler(this->db, (void*)busy_handler, this); 
     349     
    336350    return &this->public; 
    337351}