diff --git a/bbs_list.c b/bbs_list.c index 639f667..8aab3cc 100644 --- a/bbs_list.c +++ b/bbs_list.c @@ -50,14 +50,14 @@ void add_bbs(struct user_record *user) { sprintf(buffer, "%s/bbslist.sq3", conf.bbs_path); rc = sqlite3_open(buffer, &db); - + if (rc != SQLITE_OK) { dolog("Cannot open database: %s", sqlite3_errmsg(db)); sqlite3_close(db); exit(1); } - + sqlite3_busy_timeout(db, 5000); rc = sqlite3_exec(db, create_sql, 0, 0, &err_msg); if (rc != SQLITE_OK ) { @@ -116,9 +116,11 @@ void delete_bbs(struct user_record *user) { sprintf(buffer, "%s/bbslist.sq3", conf.bbs_path); rc = sqlite3_open(buffer, &db); + if (rc != SQLITE_OK) { return; } + sqlite3_busy_timeout(db, 5000); rc = sqlite3_prepare_v2(db, sql, -1, &res, 0); if (rc == SQLITE_OK) { sqlite3_bind_int(res, 1, i); @@ -165,11 +167,13 @@ void list_bbses() { sprintf(buffer, "%s/bbslist.sq3", conf.bbs_path); rc = sqlite3_open(buffer, &db); + if (rc != SQLITE_OK) { dolog("Cannot open database: %s", sqlite3_errmsg(db)); sqlite3_close(db); exit(1); } + sqlite3_busy_timeout(db, 5000); rc = sqlite3_prepare_v2(db, sql, -1, &res, 0); if (rc != SQLITE_OK) { sqlite3_close(db); diff --git a/email.c b/email.c index a1cb83d..f854128 100644 --- a/email.c +++ b/email.c @@ -65,13 +65,14 @@ void send_email(struct user_record *user) { sprintf(buffer, "%s/email.sq3", conf.bbs_path); rc = sqlite3_open(buffer, &db); + if (rc != SQLITE_OK) { dolog("Cannot open database: %s", sqlite3_errmsg(db)); sqlite3_close(db); exit(1); } - + sqlite3_busy_timeout(db, 5000); rc = sqlite3_exec(db, csql, 0, 0, &err_msg); if (rc != SQLITE_OK ) { @@ -242,13 +243,14 @@ void show_email(struct user_record *user, int msgno, int email_count, struct ema sprintf(buffer, "%s/email.sq3", conf.bbs_path); rc = sqlite3_open(buffer, &db); + if (rc != SQLITE_OK) { dolog("Cannot open database: %s", sqlite3_errmsg(db)); sqlite3_close(db); exit(1); } - + sqlite3_busy_timeout(db, 5000); rc = sqlite3_prepare_v2(db, ssql, -1, &res, 0); if (rc == SQLITE_OK) { @@ -287,6 +289,7 @@ void show_email(struct user_record *user, int msgno, int email_count, struct ema exit(1); } + sqlite3_busy_timeout(db, 5000); rc = sqlite3_prepare_v2(db, isql, -1, &res, 0); if (rc == SQLITE_OK) { @@ -320,6 +323,7 @@ void show_email(struct user_record *user, int msgno, int email_count, struct ema exit(1); } + sqlite3_busy_timeout(db, 5000); rc = sqlite3_prepare_v2(db, dsql, -1, &res, 0); if (rc == SQLITE_OK) { @@ -375,6 +379,7 @@ void list_emails(struct user_record *user) { exit(1); } + sqlite3_busy_timeout(db, 5000); rc = sqlite3_prepare_v2(db, sql, -1, &res, 0); if (rc == SQLITE_OK) { @@ -539,12 +544,14 @@ int mail_getemailcount(struct user_record *user) { sprintf(buffer, "%s/email.sq3", conf.bbs_path); rc = sqlite3_open(buffer, &db); + if (rc != SQLITE_OK) { dolog("Cannot open database: %s", sqlite3_errmsg(db)); sqlite3_close(db); exit(1); } + sqlite3_busy_timeout(db, 5000); rc = sqlite3_prepare_v2(db, sql, -1, &res, 0); if (rc == SQLITE_OK) { diff --git a/files.c b/files.c index f4298a9..c174c4d 100644 --- a/files.c +++ b/files.c @@ -656,7 +656,7 @@ void upload(struct user_record *user) { sqlite3_close(db); exit(1); } - + sqlite3_busy_timeout(db, 5000); rc = sqlite3_exec(db, create_sql, 0, 0, &err_msg); if (rc != SQLITE_OK ) { dolog("SQL error: %s", err_msg); @@ -800,6 +800,7 @@ void download(struct user_record *user) { sqlite3_close(db); exit(1); } + sqlite3_busy_timeout(db, 5000); rc = sqlite3_prepare_v2(db, ssql, -1, &res, 0); if (rc == SQLITE_OK) { @@ -872,6 +873,7 @@ void list_files(struct user_record *user) { exit(1); } + sqlite3_busy_timeout(db, 5000); rc = sqlite3_prepare_v2(db, sql, -1, &res, 0); if (rc != SQLITE_OK) { diff --git a/users.c b/users.c index 9ae84b6..2983189 100644 --- a/users.c +++ b/users.c @@ -93,7 +93,7 @@ int save_user(struct user_record *user) { exit(1); } - +sqlite3_busy_timeout(db, 5000); rc = sqlite3_prepare_v2(db, update_sql, -1, &res, 0); if (rc == SQLITE_OK) { @@ -173,7 +173,7 @@ int inst_user(struct user_record *user) { exit(1); } - +sqlite3_busy_timeout(db, 5000); rc = sqlite3_exec(db, create_sql, 0, 0, &err_msg); if (rc != SQLITE_OK ) { @@ -245,6 +245,7 @@ struct user_record *check_user_pass(char *loginname, char *password) { exit(1); } + sqlite3_busy_timeout(db, 5000); rc = sqlite3_prepare_v2(db, sql, -1, &res, 0); if (rc == SQLITE_OK) { @@ -349,6 +350,7 @@ void list_users(struct user_record *user) { sqlite3_close(db); exit(1); } + sqlite3_busy_timeout(db, 5000); rc = sqlite3_prepare_v2(db, sql, -1, &res, 0); if (rc != SQLITE_OK) { dolog("Cannot prepare statement: %s", sqlite3_errmsg(db)); @@ -394,6 +396,7 @@ int check_user(char *loginname) { exit(1); } + sqlite3_busy_timeout(db, 5000); rc = sqlite3_prepare_v2(db, sql, -1, &res, 0); if (rc == SQLITE_OK) { diff --git a/utils/fileapprove/fileapprove.c b/utils/fileapprove/fileapprove.c index e9ce7c7..f789eb6 100644 --- a/utils/fileapprove/fileapprove.c +++ b/utils/fileapprove/fileapprove.c @@ -187,6 +187,7 @@ int main(int argc, char **argv) { // populate scroll list rc = sqlite3_open(CDKparamString (¶ms, 'd'), &db); + if (rc != SQLITE_OK) { fprintf(stderr, "Cannot open database: %s", sqlite3_errmsg(db)); @@ -195,6 +196,7 @@ int main(int argc, char **argv) { endCDK(); exit(1); } + sqlite3_busy_timeout(db, 5000); rc = sqlite3_prepare_v2(db, sql_read, -1, &res, 0); if (rc != SQLITE_OK) { diff --git a/utils/filepost/filepost.c b/utils/filepost/filepost.c index a94cd11..c927e5a 100644 --- a/utils/filepost/filepost.c +++ b/utils/filepost/filepost.c @@ -55,11 +55,12 @@ int main(int argc, char **argv) { rc = sqlite3_open(argv[3], &db); - + if (rc != SQLITE_OK) { printf("Cannot open database: %s\n", sqlite3_errmsg(db)); exit(1); } + sqlite3_busy_timeout(db, 5000); rc = sqlite3_exec(db, create_sql, 0, 0, &err_msg); if (rc != SQLITE_OK ) { printf("SQL error: %s\n", err_msg); diff --git a/utils/magiftpd/magiftpd.c b/utils/magiftpd/magiftpd.c index 2834507..20b16bb 100644 --- a/utils/magiftpd/magiftpd.c +++ b/utils/magiftpd/magiftpd.c @@ -553,10 +553,12 @@ void handle_PASS(struct ftpserver *cfg, struct ftpclient *client, char *password send_msg(client, "230 User Logged in, Proceed.\r\n"); } else { rc = sqlite3_open(cfg->userdb, &db); + if (rc != SQLITE_OK) { fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db)); exit(-1); } + sqlite3_busy_timeout(db, 5000); rc = sqlite3_prepare_v2(db, sql, -1, &res, 0); if (rc == SQLITE_OK) { diff --git a/utils/ticproc/ticproc.c b/utils/ticproc/ticproc.c index a990e47..f1d7a6d 100644 --- a/utils/ticproc/ticproc.c +++ b/utils/ticproc/ticproc.c @@ -156,11 +156,12 @@ int add_file(struct ticfile_t *ticfile) { } rc = sqlite3_open(conf.file_areas[i]->database, &db); + if (rc != SQLITE_OK) { fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db)); return -1; } - + sqlite3_busy_timeout(db, 5000); rc = sqlite3_exec(db, create_sql, 0, 0, &err_msg); if (rc != SQLITE_OK) { diff --git a/utils/update_pass/update_pass.c b/utils/update_pass/update_pass.c index 8a42eea..a5a9972 100644 --- a/utils/update_pass/update_pass.c +++ b/utils/update_pass/update_pass.c @@ -77,7 +77,7 @@ int main(int argc, char **argv) { printf("Error opening database\n"); return -1; } - + sqlite3_busy_timeout(db, 5000); rc = sqlite3_exec(db, alter_table_sql, 0, 0, &err_msg); if (rc != SQLITE_OK ) { diff --git a/www_email.c b/www_email.c index fba7bac..f832ef7 100644 --- a/www_email.c +++ b/www_email.c @@ -34,8 +34,7 @@ int www_email_delete(struct user_record *user, int id) { return 0; } - - + sqlite3_busy_timeout(db, 5000); rc = sqlite3_exec(db, csql, 0, 0, &err_msg); if (rc != SQLITE_OK ) { sqlite3_free(err_msg); @@ -110,7 +109,7 @@ int www_send_email(struct user_record *user, char *recipient, char *subject, cha return 0; } - + sqlite3_busy_timeout(db, 5000); rc = sqlite3_exec(db, csql, 0, 0, &err_msg); if (rc != SQLITE_OK ) { sqlite3_free(err_msg); @@ -254,7 +253,7 @@ char *www_email_display(struct user_record *user, int email) { free(page); return NULL; } - + sqlite3_busy_timeout(db, 5000); rc = sqlite3_exec(db, email_create_sql, 0, 0, &err_msg); if (rc != SQLITE_OK ) { sqlite3_free(err_msg); @@ -573,7 +572,7 @@ char *www_email_summary(struct user_record *user) { free(page); return NULL; } - +sqlite3_busy_timeout(db, 5000); rc = sqlite3_exec(db, email_create_sql, 0, 0, &err_msg); if (rc != SQLITE_OK ) { sqlite3_free(err_msg);