Add Sqlite_Busy_Timeout

This commit is contained in:
Andrew Pamment 2017-03-22 11:51:04 +10:00
parent 04fdc083ec
commit a16735e27c
10 changed files with 36 additions and 15 deletions

View File

@ -57,7 +57,7 @@ void add_bbs(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 ) {
@ -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);

11
email.c
View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -188,6 +188,7 @@ int main(int argc, char **argv) {
// populate scroll list
rc = sqlite3_open(CDKparamString (&params, 'd'), &db);
if (rc != SQLITE_OK) {
fprintf(stderr, "Cannot open database: %s", sqlite3_errmsg(db));
sqlite3_close(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) {

View File

@ -60,6 +60,7 @@ int main(int argc, char **argv) {
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);

View File

@ -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) {

View File

@ -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) {

View File

@ -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 ) {

View File

@ -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);