Ok, after a bit of testing this evening, the close which is crashing the system has ALWAYS been the same close statement, the close after the Apache Module has initialized the data structure to process the request. I went in and made sure that each and every sqlite call is log if there is a result an error. I also did the same for the authentication code, which is where I saw the close crash once or twice yesterday.
I am NEVER capturing anything in the log file, so it looks like everything is returning the correct. I am a bit stumped right now, so if it is alright, I am going to post my code: /* *************************************************** */ /* Basic sqlite class to manage the open/close */ /* *************************************************** */ class CSQLiteDB { public: CSQLiteDB(); ~CSQLiteDB(void); int OpenV2( const char *filename, int flags, const char *zVfs ); void Close(); operator sqlite3*() { return m_db; } private: static int BusyHandler_Callback(void* data, int count); int BusyHandler(int count); sqlite3 *m_db; int m_sleepTime; }; int CSQLiteDB::BusyHandler_Callback(void* data, int count) { CSQLiteDB *This = (CSQLiteDB*) data; return This->BusyHandler(count); } CSQLiteDB::CSQLiteDB() : m_db(NULL) , m_sleepTime(0) { } CSQLiteDB::~CSQLiteDB() { Close(); } int CSQLiteDB::OpenV2( const char *filename, int flags, const char *zVfs) { int rc = sqlite3_open_v2(filename, &m_db, flags, zVfs); if( rc == SQLITE_OK) { sqliteExtInit(m_db); rc = sqlite3_busy_handler( m_db, CSQLiteDB::BusyHandler_Callback, this); } return rc; } void CSQLiteDB::Close() { if(m_db) { sqlite3 *db = m_db; m_db == NULL; sqlite3_close(db); } } int CSQLiteDB::BusyHandler(int count) { // sum of 1 to n = (n * (n + 1)) / 2 // the range is from 9 to 18 (45ms to 171ms, total 1020) if( count > 9 ) return 0; if(count > 1) { m_sleepTime += count + 8; } else { m_sleepTime = 45; } Sleep( m_sleepTime); return 1; } /* ********************************************************************* */ /* function that open/closes the db, and where we find the crash */ /* ********************************************************************* */ CSQLiteDB db; const char * pszSystemDBFile = GetSystemDBFile(); int rc = db.OpenV2( pszSystemDBFile, SQLITE_OPEN_READONLY|SQLITE_OPEN_FULLMUTEX, NULL); if(rc == SQLITE_OK) { rc = db_LoadDbConfigModuleSettings(r, db, m_configSetting); if(rc == SQLITE_OK) { if (m_configSetting->pszRootDir) { m_configSetting->pszEventFile = ap_server_root_relative( r->pool, apr_pstrcat( r->pool, GetRootDir(), "/event.xml", NULL)); m_configSetting->pszEventDB = ap_server_root_relative( r->pool, apr_pstrcat( r->pool, GetRootDir(), EVENT_DB_FILENAME, NULL)); } else { ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, "The \'Event Folder\' is NOT set yet."); } } else { ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, "Unable to load configuration (%d): %s", rc, sqlite3_errmsg(db)); } } else { ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, "Unable to open promenade db file (%d): %s", rc, GetSystemDBFile()); } db.Close(); /* THE CRASH */ /* ************************************************** */ /* function that creates the prepare statement */ /* ************************************************** */ int db_LoadDbConfigModuleSettings(request_rec *r, sqlite3 *db, struct photo_parata_cfg * pCfg) { sqlite3_stmt *stmt = NULL; const char* pzTail = NULL; int rc = sqlite3_prepare_v2(db, SQL_CMD(DBLOOKUP_GET_CATEGORY_VALUE_SQL), &stmt, &pzTail); if( rc == SQLITE_OK) { rc = GetDirectoryStringValue(r, db, stmt, SYSTEMSETTINGS, ROOTDIR, pCfg, offsetof(photo_parata_cfg, pszRootDir)); if( ::IsLicenseType( pCfg->eLicenseType, pltProfessional)) { if( rc == SQLITE_OK) rc = GetIntValue(r, db, stmt, SYSTEMSETTINGS, DEFAULTISINSLIDESHOW, pCfg, offsetof(photo_parata_cfg, iDefaultInSlideShow)); if( rc == SQLITE_OK) rc = GetIntValue(r, db, stmt, KVSSETTINGS, ENABLEFAVORITES, pCfg, offsetof(photo_parata_cfg, iEnableFavorites)); if( rc == SQLITE_OK) rc = GetIntValue(r, db, stmt, KVSSETTINGS, ISLOGINREQUIRED, pCfg, offsetof(photo_parata_cfg, iIsLoginRequired)); } } else { ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, "%s| Unable to prepare statement (%d): %s", GetProcessId(r), rc, sqlite3_errmsg(db)); } if(stmt) { rc = sqlite3_finalize(stmt); if( rc != SQLITE_OK) ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, "%s| sqlite3_finalize() --> (%d): %s", GetProcessId(r), rc, sqlite3_errmsg(db)); } return rc; } /* ************************************************************ */ /* the two functions which use the prepared statement */ /* ************************************************************ */ static int GetDirectoryStringValue( request_rec *r, sqlite3 *db, sqlite3_stmt *stmt, const char* categoryName, const char* itemName, struct photo_parata_cfg * pCfg, size_t offset) { int rc = SQLITE_OK; char** ppStr = (char**)((char*) pCfg + offset); // only load if not already loaded if( *ppStr == NULL) { rc = sqlite3_bind_text(stmt, 1, categoryName, -1, SQLITE_STATIC); if( rc != SQLITE_OK) { ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, "%s| sqlite3_bind_text(%s) --> (%d): %s", GetProcessId(r), categoryName, rc, sqlite3_errmsg(db)); return rc; } rc = sqlite3_bind_text(stmt, 2, itemName, -1, SQLITE_STATIC); if( rc != SQLITE_OK) { ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, "%s| sqlite3_bind_text(%s) --> (%d): %s", GetProcessId(r), itemName, rc, sqlite3_errmsg(db)); return rc; } if( rc == SQLITE_OK) rc = sqlite3_step(stmt); if( rc != SQLITE_ROW) { ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, "%s| sqlite3_step() --> (%d): %s", GetProcessId(r), rc, sqlite3_errmsg(db)); return rc; } char* szValue = (char*) sqlite3_column_text(stmt, 0); if( szValue && *szValue != '\0') *ppStr = ap_server_root_relative(r->pool, szValue); rc = sqlite3_reset(stmt); if( rc != SQLITE_OK) { ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, "%s| sqlite3_reset() --> (%d): %s", GetProcessId(r), rc, sqlite3_errmsg(db)); return rc; } } return rc; } static int GetIntValue( request_rec *r, sqlite3 *db, sqlite3_stmt *stmt, const char* categoryName, const char* itemName, struct photo_parata_cfg * pCfg, size_t offset) { int rc = sqlite3_bind_text(stmt, 1, categoryName, -1, SQLITE_STATIC); if( rc != SQLITE_OK) { ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, "%s| sqlite3_bind_text(%s) --> (%d): %s", GetProcessId(r), categoryName, rc, sqlite3_errmsg(db)); return rc; } rc = sqlite3_bind_text(stmt, 2, itemName, -1, SQLITE_STATIC); if( rc != SQLITE_OK) { ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, "%s| sqlite3_bind_text(%s) --> (%d): %s", GetProcessId(r), itemName, rc, sqlite3_errmsg(db)); return rc; } rc = sqlite3_step(stmt); if( rc != SQLITE_ROW) { ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, "%s| sqlite3_step() --> (%d): %s", GetProcessId(r), rc, sqlite3_errmsg(db)); return rc; } int nValue = sqlite3_column_int(stmt, 0); int* pStuctValue = (int*)((char*) pCfg + offset); *pStuctValue = nValue; rc = sqlite3_reset(stmt); if( rc != SQLITE_OK) { ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_SUCCESS, r, "%s| sqlite3_reset() --> (%d): %s", GetProcessId(r), rc, sqlite3_errmsg(db)); return rc; } return rc; } _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users