bankd: Better error messages during start-up
If something goes wrong during startup (missing CSV file, ...) let's print a more human-readable error message than just asserting. Change-Id: I95222d44eefc60ad3857fa70ccebbacce60820df
This commit is contained in:
parent
65006583c1
commit
e9e505c7c5
|
@ -384,7 +384,9 @@ int main(int argc, char **argv)
|
||||||
/* Np lock or mutex required for the pcsc_slot_names list, as this is only
|
/* Np lock or mutex required for the pcsc_slot_names list, as this is only
|
||||||
* read once during bankd initialization, when the worker threads haven't
|
* read once during bankd initialization, when the worker threads haven't
|
||||||
* started yet */
|
* started yet */
|
||||||
OSMO_ASSERT(bankd_pcsc_read_slotnames(g_bankd, "bankd_pcsc_slots.csv") == 0);
|
rc = bankd_pcsc_read_slotnames(g_bankd, "bankd_pcsc_slots.csv");
|
||||||
|
if (rc)
|
||||||
|
exit(1);
|
||||||
|
|
||||||
/* Connection towards remsim-server */
|
/* Connection towards remsim-server */
|
||||||
rc = server_conn_fsm_alloc(g_bankd, srvc);
|
rc = server_conn_fsm_alloc(g_bankd, srvc);
|
||||||
|
@ -396,16 +398,21 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* create listening socket for inbound client connections */
|
/* create listening socket for inbound client connections */
|
||||||
rc = osmo_sock_init(AF_INET, SOCK_STREAM, IPPROTO_TCP, g_bind_ip, g_bind_port, OSMO_SOCK_F_BIND);
|
rc = osmo_sock_init(AF_INET, SOCK_STREAM, IPPROTO_TCP, g_bind_ip, g_bind_port, OSMO_SOCK_F_BIND);
|
||||||
if (rc < 0)
|
if (rc < 0) {
|
||||||
|
fprintf(stderr, "Unable to create TCP socket at %s:%d: %s\n",
|
||||||
|
g_bind_ip ? g_bind_ip : "INADDR_ANY", g_bind_port, strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
|
}
|
||||||
g_bankd->accept_fd = rc;
|
g_bankd->accept_fd = rc;
|
||||||
|
|
||||||
/* create worker threads: One per reader/slot! */
|
/* create worker threads: One per reader/slot! */
|
||||||
for (i = 0; i < g_bankd->srvc.bankd.num_slots; i++) {
|
for (i = 0; i < g_bankd->srvc.bankd.num_slots; i++) {
|
||||||
struct bankd_worker *w;
|
struct bankd_worker *w;
|
||||||
w = bankd_create_worker(g_bankd, i);
|
w = bankd_create_worker(g_bankd, i);
|
||||||
if (!w)
|
if (!w) {
|
||||||
|
fprintf(stderr, "Error creating bankd worker thread\n");
|
||||||
exit(21);
|
exit(21);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
|
@ -127,12 +127,16 @@ int bankd_pcsc_read_slotnames(struct bankd *bankd, const char *csv_file)
|
||||||
size_t bytes_read;
|
size_t bytes_read;
|
||||||
struct parser_state ps;
|
struct parser_state ps;
|
||||||
|
|
||||||
if (csv_init(&p, CSV_APPEND_NULL) != 0)
|
if (csv_init(&p, CSV_APPEND_NULL) != 0) {
|
||||||
|
LOGP(DMAIN, LOGL_FATAL, "Error during csv_init\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
fp = fopen(csv_file, "rb");
|
fp = fopen(csv_file, "rb");
|
||||||
if (!fp)
|
if (!fp) {
|
||||||
|
LOGP(DMAIN, LOGL_FATAL, "Error opening %s: %s\n", csv_file, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
parser_state_init(&ps);
|
parser_state_init(&ps);
|
||||||
ps.bankd = bankd;
|
ps.bankd = bankd;
|
||||||
|
|
Loading…
Reference in New Issue