Skip to content

Commit

Permalink
fixing uninitialized vars
Browse files Browse the repository at this point in the history
  • Loading branch information
riverszhang89 committed Sep 9, 2024
1 parent 27dfed2 commit fbfc55c
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 71 deletions.
4 changes: 2 additions & 2 deletions bdb/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -9051,8 +9051,8 @@ static int call_berkdb_pgmv_rtn(bdb_state_type *bdb_state, pgmv_rtn rtn, const c

/* Process data and blob */
for (dta = 0; rc == 0 && dta < MAXDTAFILES; ++dta) {
if (blobonly && dta == 0)
continue;
if (blobonly && dta == 0)
continue;
for (stripe = 0; rc == 0 && stripe < MAXDTASTRIPE; ++stripe) {
if ((dbp = bdb_state->dbp_data[dta][stripe]) != NULL) {
rc = rtn(dbp, txn);
Expand Down
6 changes: 5 additions & 1 deletion berkdb/db/db_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,10 @@ ufid_for_recovery_record(DB_ENV *env, DB_LSN *lsn, int rectype,
case DB___db_pg_freedata:
case DB___db_pg_prepare:
case DB___db_pg_new:
case DB___db_rebuild_freelist:
case DB___db_pg_swap:
case DB___db_resize:
case DB___db_pg_swap_overflow:
case DB___ham_splitdata:
case DB___ham_replace:
case DB___ham_copypage:
Expand Down Expand Up @@ -407,7 +411,7 @@ ufid_for_recovery_record(DB_ENV *env, DB_LSN *lsn, int rectype,
* bigger transactions except rowlocks.
*/
if (rectype < 10000) {
logmsg(LOGMSG_FATAL, "got rectype %d, don't know how to handle it",
logmsg(LOGMSG_FATAL, "got rectype %d, don't know how to handle it\n",
rectype);
abort();
}
Expand Down
1 change: 1 addition & 0 deletions berkdb/db/db_pgcompact.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ __db_pgswap(dbp, txn)

h = ph = nh = pp = np = NULL;
got_hl = got_pl = got_nl = got_newl = 0;
stack = 0;

lfp = NULL;
lpgnofromfl = NULL;
Expand Down
16 changes: 7 additions & 9 deletions berkdb/db/db_rec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1959,11 +1959,12 @@ __db_pg_swap_recover(dbenv, dbtp, lsnp, op, info)
int ret, t_ret;
int check_page = gbl_check_page_in_recovery;

pagep = pp = newp = nextp = prevp = NULL;
hmodified = ppmodified = newmodified = nhmodified = phmodified = 0;

REC_PRINT(__db_pg_swap_print);
REC_INTRO(__db_pg_swap_read, 0);

pagep = pp = newp = nextp = prevp = NULL;

if ((ret = __memp_fget(mpf, &argp->pgno, 0, &pagep)) != 0) {
ret = __db_pgerr(file_dbp, argp->pgno, ret);
pagep = NULL;
Expand All @@ -1975,8 +1976,6 @@ __db_pg_swap_recover(dbenv, dbtp, lsnp, op, info)
__dir_pg(mpf, argp->pgno, (u_int8_t *)pagep, 1);
}

hmodified = ppmodified = newmodified = nhmodified = phmodified = 0;

if (gbl_pgmv_verbose) {
logmsg(LOGMSG_WARN, "replacing pgno %u with newp %u before lsn %d:%d, "
"page lsn %d:%d, after lsn %d:%d\n",
Expand Down Expand Up @@ -2243,6 +2242,7 @@ __db_resize_recover(dbenv, dbtp, lsnp, op, info)

h = NULL;
meta = NULL;
modified = 0;

REC_PRINT(__db_resize_print);
REC_INTRO(__db_resize_read, 0);
Expand All @@ -2259,8 +2259,6 @@ __db_resize_recover(dbenv, dbtp, lsnp, op, info)
__dir_pg(mpf, argp->meta_pgno, (u_int8_t *)meta, 1);
}

modified = 0;

cmp_n = log_compare(lsnp, &LSN(meta));
cmp_p = log_compare(&LSN(meta), &argp->meta_lsn);

Expand Down Expand Up @@ -2345,12 +2343,12 @@ __db_pg_swap_overflow_recover(dbenv, dbtp, lsnp, op, info)
int ret, t_ret;
int ohmodified, pohmodified, nohmodified, hmodified, newohmodified;

REC_PRINT(__db_pg_swap_overflow_print);
REC_INTRO(__db_pg_swap_overflow_read, 0);

oh = poh = noh = h = newoh = NULL;
ohmodified = pohmodified = nohmodified = hmodified = newohmodified = 0;

REC_PRINT(__db_pg_swap_overflow_print);
REC_INTRO(__db_pg_swap_overflow_read, 0);

if ((ret = __memp_fget(mpf, &argp->pgno, 0, &oh)) != 0) {
ret = __db_pgerr(file_dbp, argp->pgno, ret);
oh = NULL;
Expand Down
2 changes: 1 addition & 1 deletion berkdb/mp/mp_fput.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static const char revid[] = "$Id: mp_fput.c,v 11.48 2003/09/30 17:12:00 sue Exp
#include "comdb2_atomic.h"

extern int gbl_enable_cache_internal_nodes;
int gbl_memp_fput_abort_on_double_retur; = 0;
int gbl_memp_fput_abort_on_double_return = 0;

static void __memp_reset_lru __P((DB_ENV *, REGINFO *));

Expand Down
32 changes: 14 additions & 18 deletions db/db_tunables.h
Original file line number Diff line number Diff line change
Expand Up @@ -2426,27 +2426,23 @@ REGISTER_TUNABLE("sc_status_max_rows", "Max number of rows returned in comdb2_sc
TUNABLE_INTEGER, &gbl_sc_status_max_rows, 0, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("rep_process_pstack_time", "pstack the server if rep_process runs longer than time specified in secs (Default: 30s)",
TUNABLE_INTEGER, &gbl_rep_process_pstack_time, 0, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("pgmv_verbose",
"Set to true to print debug trace for pgmv",
TUNABLE_BOOLEAN, &gbl_pgmv_verbose, 0, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("pgmv_verbose", "Set to true to print debug trace for pgmv", TUNABLE_BOOLEAN, &gbl_pgmv_verbose, 0,
NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("pgmv_unsafe_db_resize",
"Set to true to resize a file even if pages may still be referenced in the log",
TUNABLE_BOOLEAN, &gbl_pgmv_unsafe_db_resize, 0, NULL, NULL, NULL, NULL);
"Set to true to resize a file even if pages may still be referenced in the log", TUNABLE_BOOLEAN,
&gbl_pgmv_unsafe_db_resize, 0, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("pgmv_max_num_pages_swapped_per_txn",
"Max number of pages that may be swapped within a single transaction",
TUNABLE_INTEGER, &gbl_pgmv_max_num_pages_swapped_per_txn, 0, NULL, NULL, NULL, NULL);
"Max number of pages that may be swapped within a single transaction", TUNABLE_INTEGER,
&gbl_pgmv_max_num_pages_swapped_per_txn, 0, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("pgmv_only_process_pages_in_bufferpool",
"Set to true to make pgmv only process pages in the bufferpool",
TUNABLE_BOOLEAN, &gbl_pgmv_only_process_pages_in_bufferpool, 0, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("pgmv_thr",
"Set to true to move pages in background",
TUNABLE_BOOLEAN, &gbl_pgmv_thr, 0, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("pgmv_thr_run_interval_ms",
"Number of milliseconds we poll for each pgmv iteration",
TUNABLE_INTEGER, &gbl_pgmv_thr_run_interval_ms, 0, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("pgmv_thr_pause",
"Number of milliseconds we poll for each pgmv iteration",
TUNABLE_INTEGER, &gbl_pgmv_thr_pause, 0, NULL, NULL, NULL, NULL);
"Set to true to make pgmv only process pages in the bufferpool", TUNABLE_BOOLEAN,
&gbl_pgmv_only_process_pages_in_bufferpool, 0, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("pgmv_thr", "Set to true to move pages in background", TUNABLE_BOOLEAN, &gbl_pgmv_thr, 0, NULL, NULL,
NULL, NULL);
REGISTER_TUNABLE("pgmv_thr_run_interval_ms", "Number of milliseconds we poll for each pgmv iteration", TUNABLE_INTEGER,
&gbl_pgmv_thr_run_interval_ms, 0, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("pgmv_thr_pause", "Number of milliseconds we poll for each pgmv iteration", TUNABLE_INTEGER,
&gbl_pgmv_thr_pause, 0, NULL, NULL, NULL, NULL);
REGISTER_TUNABLE("memp_fput_abort_on_double_return",
"Number of milliseconds we poll for each pgmv iteration",
TUNABLE_INTEGER, &gbl_memp_fput_abort_on_double_return, 0, NULL, NULL, NULL, NULL);
Expand Down
57 changes: 28 additions & 29 deletions db/glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -6331,19 +6331,19 @@ typedef int (*bdb_pgmv_rtn)(bdb_state_type *);
static int call_bdb_pgmv_rtn(const char *table, bdb_pgmv_rtn rtn)
{
int ret;
dbtable *db;
dbtable *db;

if (table == NULL)
return -1;
if (table == NULL)
return -1;

db = get_dbtable_by_name(table);
if (db == NULL) {
logmsg(LOGMSG_ERROR, "%s: table \"%s\" not found", __func__, table);
ret = -1;
} else {
ret = rtn(get_bdb_handle(db, AUXDB_NONE));
}
return ret;
db = get_dbtable_by_name(table);
if (db == NULL) {
logmsg(LOGMSG_ERROR, "%s: table \"%s\" not found", __func__, table);
ret = -1;
} else {
ret = rtn(get_bdb_handle(db, AUXDB_NONE));
}
return ret;
}

int rebuild_freelist(const char *table)
Expand Down Expand Up @@ -6374,38 +6374,37 @@ void *pgmv_thr(void *unused)
{
int i;
struct dbtable *table;
const char *name;
int remaining;
const char *name;
int remaining;

thrman_register(THRTYPE_PGMV);
bdb_thread_event(thedb->bdb_env, BDBTHR_EVENT_START_RDWR);
remaining = gbl_pgmv_thr_overflow_run_interval_ms;
remaining = gbl_pgmv_thr_overflow_run_interval_ms;

while (!db_is_exiting()) {
if (gbl_pgmv_thr_pause) {
if (gbl_pgmv_thr_pause) {
poll(NULL, 0, gbl_pgmv_thr_run_interval_ms);
continue;
}
}

rdlock_schema_lk();
for (i = 0; i != thedb->num_dbs; ++i) {
rdlock_schema_lk();
for (i = 0; i != thedb->num_dbs; ++i) {
table = thedb->dbs[i];
name = table->tablename;
if (table->dbtype != DBTYPE_TAGGED_TABLE ||
strncasecmp(name, "sqlite_", strlen("sqlite_")) == 0 ||
name = table->tablename;
if (table->dbtype != DBTYPE_TAGGED_TABLE || strncasecmp(name, "sqlite_", strlen("sqlite_")) == 0 ||
strncasecmp(name, "comdb2_", strlen("comdb2_")) == 0) {
continue;
}
rebuild_freelist(name);
pgswap(name);
if (remaining <= 0) {
pgswap_overflow(name);
remaining = gbl_pgmv_thr_overflow_run_interval_ms;
}
}
unlock_schema_lk();
poll(NULL, 0, gbl_pgmv_thr_run_interval_ms);
remaining -= gbl_pgmv_thr_run_interval_ms;
if (remaining <= 0) {
pgswap_overflow(name);
remaining = gbl_pgmv_thr_overflow_run_interval_ms;
}
}
unlock_schema_lk();
poll(NULL, 0, gbl_pgmv_thr_run_interval_ms);
remaining -= gbl_pgmv_thr_run_interval_ms;
}
bdb_thread_event(thedb->bdb_env, BDBTHR_EVENT_DONE_RDWR);
return NULL;
Expand Down
16 changes: 5 additions & 11 deletions db/thrman.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,17 +464,11 @@ static int thrman_check_threads_stopped_ll(void *context)
thr_type_counts[self->type]--;

if (0 ==
thr_type_counts[THRTYPE_OSQL] + thr_type_counts[THRTYPE_APPSOCK] +
thr_type_counts[THRTYPE_APPSOCK_POOL] +
thr_type_counts[THRTYPE_APPSOCK_SQL] +
thr_type_counts[THRTYPE_CONSUMER] + thr_type_counts[THRTYPE_SQL] +
thr_type_counts[THRTYPE_SQLPOOL] +
thr_type_counts[THRTYPE_SQLENGINEPOOL] +
thr_type_counts[THRTYPE_VERIFY] + thr_type_counts[THRTYPE_ANALYZE] +
thr_type_counts[THRTYPE_PURGEBLKSEQ] +
thr_type_counts[THRTYPE_PGLOGS_ASOF] +
thr_type_counts[THRTYPE_TRIGGER] +
thr_type_counts[THRTYPE_PGMV])
thr_type_counts[THRTYPE_OSQL] + thr_type_counts[THRTYPE_APPSOCK] + thr_type_counts[THRTYPE_APPSOCK_POOL] +
thr_type_counts[THRTYPE_APPSOCK_SQL] + thr_type_counts[THRTYPE_CONSUMER] + thr_type_counts[THRTYPE_SQL] +
thr_type_counts[THRTYPE_SQLPOOL] + thr_type_counts[THRTYPE_SQLENGINEPOOL] +
thr_type_counts[THRTYPE_VERIFY] + thr_type_counts[THRTYPE_ANALYZE] + thr_type_counts[THRTYPE_PURGEBLKSEQ] +
thr_type_counts[THRTYPE_PGLOGS_ASOF] + thr_type_counts[THRTYPE_TRIGGER] + thr_type_counts[THRTYPE_PGMV])
all_gone = 1;

/* if we're exiting then we don't want a schema change thread running */
Expand Down

0 comments on commit fbfc55c

Please sign in to comment.