sms.db: silence libdbi warnings on out-of-range index
Apparently, since libdbi 0.9.0 aka 0.9.0-5 on debian-testing, osmo-msc barfs numerous libdbi warnings whenever a query rightfully returns no rows. Trivially query whether there are any rows first by adding an inline wrap function next_row(). Silenced: DDB <000d> ../../../../src/osmo-msc/src/libmsc/db.c:188 DBI: -6: An invalid or out-of-range index was passed to libdbi DDB <000d> ../../../src/libosmocore/src/backtrace.c:47 backtrace() returned 11 addresses DDB <000d> ../../../src/libosmocore/src/backtrace.c:57 /usr/local/bin/osmo-msc(+0xfb81) [0x555555563b81] DDB <000d> ../../../src/libosmocore/src/backtrace.c:57 /usr/lib/x86_64-linux-gnu/libdbi.so.1(_error_handler+0x99) [0x7ffff63f5c39] DDB <000d> ../../../src/libosmocore/src/backtrace.c:57 /usr/lib/x86_64-linux-gnu/libdbi.so.1(dbi_result_next_row+0x3d) [0x7ffff63f785d] DDB <000d> ../../../src/libosmocore/src/backtrace.c:57 /usr/local/bin/osmo-msc(+0x11172) [0x555555565172] DDB <000d> ../../../src/libosmocore/src/backtrace.c:57 /usr/local/bin/osmo-msc(+0x1e6bc) [0x5555555726bc] DDB <000d> ../../../src/libosmocore/src/backtrace.c:57 /usr/local/bin/osmo-msc(+0x1e7f6) [0x5555555727f6] DDB <000d> ../../../src/libosmocore/src/backtrace.c:57 /usr/local/bin/osmo-msc(+0x1f1d2) [0x5555555731d2] DDB <000d> ../../../src/libosmocore/src/backtrace.c:57 /usr/local/bin/osmo-msc(+0xbb86) [0x55555555fb86] DDB <000d> ../../../src/libosmocore/src/backtrace.c:57 /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1) [0x7ffff5cfe561] DDB <000d> ../../../src/libosmocore/src/backtrace.c:57 /usr/local/bin/osmo-msc(+0xbfba) [0x55555555ffba] Related: OS#2667 Change-Id: Ib8993c8db171d1e845a6297deef137d18506cda3
This commit is contained in:
parent
50d0900916
commit
db8272921d
|
@ -181,6 +181,13 @@ static const char *create_stmts[] = {
|
||||||
")",
|
")",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline int next_row(dbi_result result)
|
||||||
|
{
|
||||||
|
if (!dbi_result_has_next_row(result))
|
||||||
|
return 0;
|
||||||
|
return dbi_result_next_row(result);
|
||||||
|
}
|
||||||
|
|
||||||
void db_error_func(dbi_conn conn, void *data)
|
void db_error_func(dbi_conn conn, void *data)
|
||||||
{
|
{
|
||||||
const char *msg;
|
const char *msg;
|
||||||
|
@ -318,7 +325,7 @@ static int update_db_revision_3(void)
|
||||||
"Failed fetch messages from the old SMS table (upgrade from rev 3).\n");
|
"Failed fetch messages from the old SMS table (upgrade from rev 3).\n");
|
||||||
goto rollback;
|
goto rollback;
|
||||||
}
|
}
|
||||||
while (dbi_result_next_row(result)) {
|
while (next_row(result)) {
|
||||||
sms = sms_from_result_v3(result);
|
sms = sms_from_result_v3(result);
|
||||||
if (db_sms_store(sms) != 0) {
|
if (db_sms_store(sms) != 0) {
|
||||||
LOGP(DDB, LOGL_ERROR, "Failed to store message to the new SMS table(upgrade from rev 3).\n");
|
LOGP(DDB, LOGL_ERROR, "Failed to store message to the new SMS table(upgrade from rev 3).\n");
|
||||||
|
@ -464,7 +471,7 @@ static int update_db_revision_4(void)
|
||||||
"Failed fetch messages from the old SMS table (upgrade from rev 4).\n");
|
"Failed fetch messages from the old SMS table (upgrade from rev 4).\n");
|
||||||
goto rollback;
|
goto rollback;
|
||||||
}
|
}
|
||||||
while (dbi_result_next_row(result)) {
|
while (next_row(result)) {
|
||||||
sms = sms_from_result_v4(result);
|
sms = sms_from_result_v4(result);
|
||||||
if (db_sms_store(sms) != 0) {
|
if (db_sms_store(sms) != 0) {
|
||||||
LOGP(DDB, LOGL_ERROR, "Failed to store message to the new SMS table(upgrade from rev 4).\n");
|
LOGP(DDB, LOGL_ERROR, "Failed to store message to the new SMS table(upgrade from rev 4).\n");
|
||||||
|
@ -540,7 +547,7 @@ static int check_db_revision(void)
|
||||||
if (!result)
|
if (!result)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
if (!dbi_result_next_row(result)) {
|
if (!next_row(result)) {
|
||||||
dbi_result_free(result);
|
dbi_result_free(result);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -787,7 +794,7 @@ struct gsm_sms *db_sms_get(struct gsm_network *net, unsigned long long id)
|
||||||
if (!result)
|
if (!result)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!dbi_result_next_row(result)) {
|
if (!next_row(result)) {
|
||||||
dbi_result_free(result);
|
dbi_result_free(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -817,7 +824,7 @@ struct gsm_sms *db_sms_get_next_unsent(struct gsm_network *net,
|
||||||
if (!result)
|
if (!result)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!dbi_result_next_row(result)) {
|
if (!next_row(result)) {
|
||||||
dbi_result_free(result);
|
dbi_result_free(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -858,7 +865,7 @@ struct gsm_sms *db_sms_get_unsent_for_subscr(struct vlr_subscr *vsub,
|
||||||
if (!result)
|
if (!result)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!dbi_result_next_row(result)) {
|
if (!next_row(result)) {
|
||||||
dbi_result_free(result);
|
dbi_result_free(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -891,7 +898,7 @@ struct gsm_sms *db_sms_get_next_unsent_rr_msisdn(struct gsm_network *net,
|
||||||
if (!result)
|
if (!result)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!dbi_result_next_row(result)) {
|
if (!next_row(result)) {
|
||||||
dbi_result_free(result);
|
dbi_result_free(result);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue