瀏覽代碼

modules_k/dialog: Clear dialog and dialog variable tables after
loading dialogs from database into memory if DB_MODE_SHUTDOWN is
used.

- Closes Flyspray issue #126 ('3.x dialog module: dialogs stay in
database when in "shutdown only" mode').

Timo Reimann 14 年之前
父節點
當前提交
76fc55be01
共有 1 個文件被更改,包括 14 次插入0 次删除
  1. 14 0
      modules_k/dialog/dlg_db_handler.c

+ 14 - 0
modules_k/dialog/dlg_db_handler.c

@@ -436,6 +436,13 @@ static int load_dialog_info_from_db(int dlg_hash_size, int fetch_num_rows)
 
 	}while (nr_rows>0);
 
+	if (dlg_db_mode==DB_MODE_SHUTDOWN) {
+		if (dialog_dbf.delete(dialog_db_handle, 0, 0, 0, 0) < 0) {
+			LM_ERR("failed to clear dialog table\n");
+			goto error;
+		}
+	}
+
 end:
 	dialog_dbf.free_result(dialog_db_handle, res);
 	return 0;
@@ -546,6 +553,13 @@ static int load_dialog_vars_from_db(int fetch_num_rows)
 
 	}while (nr_rows>0);
 
+	if (dlg_db_mode==DB_MODE_SHUTDOWN) {
+		if (dialog_dbf.delete(dialog_db_handle, 0, 0, 0, 0) < 0) {
+			LM_ERR("failed to clear dialog variable table\n");
+			goto error;
+		}
+	}
+
 end:
 	dialog_dbf.free_result(dialog_db_handle, res);
 	return 0;