Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177341230
D59344.1794156133.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D59344.1794156133.diff
View Options
diff --git a/sbin/hastctl/hastctl.c b/sbin/hastctl/hastctl.c
--- a/sbin/hastctl/hastctl.c
+++ b/sbin/hastctl/hastctl.c
@@ -59,6 +59,7 @@
CMD_ROLE,
CMD_STATUS,
CMD_DUMP,
+ CMD_STOP,
CMD_LIST
};
@@ -430,6 +431,9 @@
} else if (strcmp(argv[1], "dump") == 0) {
cmd = CMD_DUMP;
optstr = "c:dh";
+ } else if (strcmp(argv[1], "stop") == 0) {
+ cmd = CMD_STOP;
+ optstr = "c:dh";
} else
usage();
@@ -524,6 +528,13 @@
nv_add_string(nv, argv[ii], "resource%d", ii);
}
break;
+ case CMD_STOP:
+ /* Stop hastd. */
+ if (argc > 0)
+ usage();
+ nv = nv_alloc();
+ nv_add_uint8(nv, HASTCTL_CMD_STOP, "cmd");
+ break;
default:
PJDLOG_ABORT("Impossible command!");
}
@@ -574,6 +585,9 @@
case CMD_STATUS:
error = control_status(nv);
break;
+ case CMD_STOP:
+ error = 0;
+ break;
default:
PJDLOG_ABORT("Impossible command!");
}
diff --git a/sbin/hastd/control.c b/sbin/hastd/control.c
--- a/sbin/hastd/control.c
+++ b/sbin/hastd/control.c
@@ -300,6 +300,15 @@
control_status_worker(res, nvout, no);
}
+static void
+control_stop(struct hastd_config *cfg, struct nv *nvout)
+{
+ pjdlog_info("Stop message received.");
+ (void)cfg;
+ (void)nvout;
+ sigexit_received = true;
+}
+
void
control_handle(struct hastd_config *cfg)
{
@@ -341,6 +350,14 @@
error = 0;
+ /* The stop command does not expect any arguments. */
+ if (cmd == HASTCTL_CMD_STOP) {
+ control_stop(cfg, nvout);
+ if (nv_error(nvout) != 0)
+ goto close;
+ goto fail;
+ }
+
str = nv_get_string(nvin, "resource0");
if (str == NULL) {
pjdlog_error("Control header is missing 'resource0' field.");
diff --git a/sbin/hastd/hast.h b/sbin/hastd/hast.h
--- a/sbin/hastd/hast.h
+++ b/sbin/hastd/hast.h
@@ -66,6 +66,7 @@
#define HASTCTL_CMD_UNKNOWN 0
#define HASTCTL_CMD_SETROLE 1
#define HASTCTL_CMD_STATUS 2
+#define HASTCTL_CMD_STOP 3
#define HAST_ROLE_UNDEF 0
#define HAST_ROLE_INIT 1
diff --git a/sbin/hastd/hastd.c b/sbin/hastd/hastd.c
--- a/sbin/hastd/hastd.c
+++ b/sbin/hastd/hastd.c
@@ -724,7 +724,6 @@
{
struct hast_resource *res;
- pjdlog_info("Termination signal received, exiting.");
TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) {
if (res->hr_workerpid == 0)
continue;
@@ -1044,10 +1043,8 @@
switch (signo) {
case SIGINT:
case SIGTERM:
+ pjdlog_info("Termination signal received.");
sigexit_received = true;
- terminate_workers();
- proto_close(cfg->hc_controlconn);
- exit(EX_OK);
break;
case SIGCHLD:
child_exit();
@@ -1077,6 +1074,8 @@
for (;;) {
check_signals();
+ if (sigexit_received)
+ break;
/* Setup descriptors for select(2). */
FD_ZERO(&rfds);
@@ -1135,6 +1134,8 @@
* info about terminated workers in the meantime.
*/
check_signals();
+ if (sigexit_received)
+ break;
if (FD_ISSET(proto_descriptor(cfg->hc_controlconn), &rfds))
control_handle(cfg);
@@ -1170,6 +1171,9 @@
}
}
}
+ terminate_workers();
+ proto_close(cfg->hc_controlconn);
+ exit(EX_OK);
}
static void
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 8, 4:42 PM (7 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41566192
Default Alt Text
D59344.1794156133.diff (2 KB)
Attached To
Mode
D59344: hastd: Add a stop control message
Attached
Detach File
Event Timeline