summaryrefslogtreecommitdiffstats
path: root/sbin/hastd
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2011-09-27 07:57:15 +0000
committerpjd <pjd@FreeBSD.org>2011-09-27 07:57:15 +0000
commit26b0e1eedd0a8adf257ee4b8b661780f92d22bcf (patch)
tree95bd2828c92c5bc3bd22be047dd7280727d08682 /sbin/hastd
parentff11c3069e6db5789566bf2006ba6c8976c45e7c (diff)
downloadFreeBSD-src-26b0e1eedd0a8adf257ee4b8b661780f92d22bcf.zip
FreeBSD-src-26b0e1eedd0a8adf257ee4b8b661780f92d22bcf.tar.gz
Prefer PJDLOG_ASSERT() and PJDLOG_ABORT() over assert() and abort().
pjdlog versions will log problem to syslog when application is running in background. MFC after: 3 days
Diffstat (limited to 'sbin/hastd')
-rw-r--r--sbin/hastd/control.c19
-rw-r--r--sbin/hastd/parse.y41
-rw-r--r--sbin/hastd/secondary.c4
3 files changed, 31 insertions, 33 deletions
diff --git a/sbin/hastd/control.c b/sbin/hastd/control.c
index 57a1c8a..93bfbb7 100644
--- a/sbin/hastd/control.c
+++ b/sbin/hastd/control.c
@@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/wait.h>
-#include <assert.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h>
@@ -82,8 +81,8 @@ control_set_role_common(struct hastd_config *cfg, struct nv *nvout,
nv_add_string(nvout, name, "resource%u", no);
if (res == NULL) {
- assert(cfg != NULL);
- assert(name != NULL);
+ PJDLOG_ASSERT(cfg != NULL);
+ PJDLOG_ASSERT(name != NULL);
TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) {
if (strcmp(res->hr_name, name) == 0)
@@ -94,7 +93,7 @@ control_set_role_common(struct hastd_config *cfg, struct nv *nvout,
return;
}
}
- assert(res != NULL);
+ PJDLOG_ASSERT(res != NULL);
/* Send previous role back. */
nv_add_string(nvout, role2str(res->hr_role), "role%u", no);
@@ -222,9 +221,9 @@ control_status(struct hastd_config *cfg, struct nv *nvout,
struct hast_resource *res, const char *name, unsigned int no)
{
- assert(cfg != NULL);
- assert(nvout != NULL);
- assert(name != NULL);
+ PJDLOG_ASSERT(cfg != NULL);
+ PJDLOG_ASSERT(nvout != NULL);
+ PJDLOG_ASSERT(name != NULL);
/* Name is always needed. */
nv_add_string(nvout, name, "resource%u", no);
@@ -239,7 +238,7 @@ control_status(struct hastd_config *cfg, struct nv *nvout,
return;
}
}
- assert(res != NULL);
+ PJDLOG_ASSERT(res != NULL);
nv_add_string(nvout, res->hr_provname, "provname%u", no);
nv_add_string(nvout, res->hr_localpath, "localpath%u", no);
nv_add_string(nvout, res->hr_remoteaddr, "remoteaddr%u", no);
@@ -267,7 +266,7 @@ control_status(struct hastd_config *cfg, struct nv *nvout,
switch (res->hr_role) {
case HAST_ROLE_PRIMARY:
- assert(res->hr_workerpid != 0);
+ PJDLOG_ASSERT(res->hr_workerpid != 0);
/* FALLTHROUGH */
case HAST_ROLE_SECONDARY:
if (res->hr_workerpid != 0)
@@ -470,7 +469,7 @@ ctrl_thread(void *arg)
* something related to us has changes, it sends reload
* message to us.
*/
- assert(res->hr_role == HAST_ROLE_PRIMARY);
+ PJDLOG_ASSERT(res->hr_role == HAST_ROLE_PRIMARY);
primary_config_reload(res, nvin);
nv_add_int16(nvout, 0, "error");
break;
diff --git a/sbin/hastd/parse.y b/sbin/hastd/parse.y
index 6e8351d..e5c25a4 100644
--- a/sbin/hastd/parse.y
+++ b/sbin/hastd/parse.y
@@ -38,7 +38,6 @@
#include <arpa/inet.h>
-#include <assert.h>
#include <err.h>
#include <errno.h>
#include <stdio.h>
@@ -282,9 +281,9 @@ yy_config_parse(const char *config, bool exitonerror)
}
}
TAILQ_FOREACH(curres, &lconfig->hc_resources, hr_next) {
- assert(curres->hr_provname[0] != '\0');
- assert(curres->hr_localpath[0] != '\0');
- assert(curres->hr_remoteaddr[0] != '\0');
+ PJDLOG_ASSERT(curres->hr_provname[0] != '\0');
+ PJDLOG_ASSERT(curres->hr_localpath[0] != '\0');
+ PJDLOG_ASSERT(curres->hr_remoteaddr[0] != '\0');
if (curres->hr_replication == -1) {
/*
@@ -426,7 +425,7 @@ control_statement: CONTROL STR
}
break;
default:
- assert(!"control at wrong depth level");
+ PJDLOG_ABORT("control at wrong depth level");
}
free($2);
}
@@ -460,7 +459,7 @@ listen_statement: LISTEN STR
free(lst);
break;
default:
- assert(!"listen at wrong depth level");
+ PJDLOG_ABORT("listen at wrong depth level");
}
free($2);
}
@@ -477,7 +476,7 @@ replication_statement: REPLICATION replication_type
curres->hr_replication = $2;
break;
default:
- assert(!"replication at wrong depth level");
+ PJDLOG_ABORT("replication at wrong depth level");
}
}
;
@@ -501,7 +500,7 @@ checksum_statement: CHECKSUM checksum_type
curres->hr_checksum = $2;
break;
default:
- assert(!"checksum at wrong depth level");
+ PJDLOG_ABORT("checksum at wrong depth level");
}
}
;
@@ -525,7 +524,7 @@ compression_statement: COMPRESSION compression_type
curres->hr_compression = $2;
break;
default:
- assert(!"compression at wrong depth level");
+ PJDLOG_ABORT("compression at wrong depth level");
}
}
;
@@ -553,7 +552,7 @@ timeout_statement: TIMEOUT NUM
curres->hr_timeout = $2;
break;
default:
- assert(!"timeout at wrong depth level");
+ PJDLOG_ABORT("timeout at wrong depth level");
}
}
;
@@ -581,7 +580,7 @@ exec_statement: EXEC STR
}
break;
default:
- assert(!"exec at wrong depth level");
+ PJDLOG_ABORT("exec at wrong depth level");
}
free($2);
}
@@ -605,7 +604,7 @@ node_start: STR
mynode = true;
break;
default:
- assert(!"invalid isitme() return value");
+ PJDLOG_ABORT("invalid isitme() return value");
}
free($1);
}
@@ -785,7 +784,7 @@ name_statement: NAME STR
case 2:
if (!mynode)
break;
- assert(curres != NULL);
+ PJDLOG_ASSERT(curres != NULL);
if (strlcpy(curres->hr_provname, $2,
sizeof(curres->hr_provname)) >=
sizeof(curres->hr_provname)) {
@@ -795,7 +794,7 @@ name_statement: NAME STR
}
break;
default:
- assert(!"name at wrong depth level");
+ PJDLOG_ABORT("name at wrong depth level");
}
free($2);
}
@@ -816,7 +815,7 @@ local_statement: LOCAL STR
case 2:
if (!mynode)
break;
- assert(curres != NULL);
+ PJDLOG_ASSERT(curres != NULL);
if (strlcpy(curres->hr_localpath, $2,
sizeof(curres->hr_localpath)) >=
sizeof(curres->hr_localpath)) {
@@ -826,7 +825,7 @@ local_statement: LOCAL STR
}
break;
default:
- assert(!"local at wrong depth level");
+ PJDLOG_ABORT("local at wrong depth level");
}
free($2);
}
@@ -851,7 +850,7 @@ resource_node_start: STR
mynode = hadmynode = true;
break;
default:
- assert(!"invalid isitme() return value");
+ PJDLOG_ABORT("invalid isitme() return value");
}
}
free($1);
@@ -875,9 +874,9 @@ resource_node_entry:
remote_statement: REMOTE remote_str
{
- assert(depth == 2);
+ PJDLOG_ASSERT(depth == 2);
if (mynode) {
- assert(curres != NULL);
+ PJDLOG_ASSERT(curres != NULL);
if (strlcpy(curres->hr_remoteaddr, $2,
sizeof(curres->hr_remoteaddr)) >=
sizeof(curres->hr_remoteaddr)) {
@@ -898,9 +897,9 @@ remote_str:
source_statement: SOURCE STR
{
- assert(depth == 2);
+ PJDLOG_ASSERT(depth == 2);
if (mynode) {
- assert(curres != NULL);
+ PJDLOG_ASSERT(curres != NULL);
if (strlcpy(curres->hr_sourceaddr, $2,
sizeof(curres->hr_sourceaddr)) >=
sizeof(curres->hr_sourceaddr)) {
diff --git a/sbin/hastd/secondary.c b/sbin/hastd/secondary.c
index 7120d3d..fc0c898 100644
--- a/sbin/hastd/secondary.c
+++ b/sbin/hastd/secondary.c
@@ -791,8 +791,8 @@ send_thread(void *arg)
length = 0;
break;
default:
- abort();
- break;
+ PJDLOG_ABORT("Unexpected command (cmd=%hhu).",
+ hio->hio_cmd);
}
if (hio->hio_error != 0)
nv_add_int16(nvout, hio->hio_error, "error");
OpenPOWER on IntegriCloud