summaryrefslogtreecommitdiffstats
path: root/utils/mirror_vfd
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@lbl.gov>2022-04-26 16:07:15 (GMT)
committerGitHub <noreply@github.com>2022-04-26 16:07:15 (GMT)
commit417ee1393b425d5c7c998562e7fb492e28928643 (patch)
treed48c7a30907029af36b5b82c81bc0eb7f835082c /utils/mirror_vfd
parent0fffb26c013146cc817ab1c9f2956ad84919a63e (diff)
downloadhdf5-417ee1393b425d5c7c998562e7fb492e28928643.zip
hdf5-417ee1393b425d5c7c998562e7fb492e28928643.tar.gz
hdf5-417ee1393b425d5c7c998562e7fb492e28928643.tar.bz2
Correct concurrency bugs when running tests, along with a bugfix & small warning cleanup (#1683)
* Correct concurrency bugs when running tests, along with a bugfix & small warning cleanup. * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'utils/mirror_vfd')
-rw-r--r--utils/mirror_vfd/mirror_server.c28
-rw-r--r--utils/mirror_vfd/mirror_server_stop.c13
2 files changed, 33 insertions, 8 deletions
diff --git a/utils/mirror_vfd/mirror_server.c b/utils/mirror_vfd/mirror_server.c
index 5381d95..d6b5254 100644
--- a/utils/mirror_vfd/mirror_server.c
+++ b/utils/mirror_vfd/mirror_server.c
@@ -46,11 +46,8 @@
#ifdef H5_HAVE_MIRROR_VFD
-#define MAXBUF 2048 /* max buffer length. */
-#define LISTENQ 80 /* max pending mirrorS requests */
-#define DEFAULT_PORT 3000 /* default listening port */
-#define MAX_PORT_LOOPS 20 /* max iteratations through port range */
-#define PORT_LOOP_RETRY_DELAY 1 /* seconds to wait between port scans */
+#define LISTENQ 80 /* max pending mirrorS requests */
+#define DEFAULT_PORT 3000 /* default listening port */
/* semi-unique "magic" numbers to sanity-check structure pointers */
#define OP_ARGS_MAGIC 0xCF074379u
@@ -211,8 +208,8 @@ parse_args(int argc, char **argv, struct op_args *args_out)
return -1;
}
- /* Loop over arguments after program name and writer_path */
- for (i = 2; i < argc; i++) {
+ /* Loop over arguments after program name */
+ for (i = 1; i < argc; i++) {
if (!HDstrncmp(argv[i], "-h", 3) || !HDstrncmp(argv[i], "--help", 7)) {
mirror_log(NULL, V_INFO, "found help argument");
args_out->help = 1;
@@ -536,10 +533,27 @@ handle_requests(struct server_run *run)
if (!HDstrncmp("SHUTDOWN", mybuf, 8)) {
/* Stop operation if told to stop */
mirror_log(run->loginfo, V_INFO, "received SHUTDOWN!", ret);
+
+ /* Confirm operation */
+ if ((ret = HDwrite(connfd, "CLOSING", 8)) < 0) {
+ mirror_log(run->loginfo, V_ERR, "write:%d", ret);
+ HDclose(connfd);
+ connfd = -1;
+ goto error;
+ }
+
HDclose(connfd);
connfd = -1;
goto done;
} /* end if explicit "SHUTDOWN" directive */
+ if (!HDstrncmp("CONFIRM", mybuf, 7)) {
+ /* Confirm operation */
+ if ((ret = HDwrite(connfd, "ALIVE", 6)) < 0) {
+ mirror_log(run->loginfo, V_ERR, "write:%d", ret);
+ goto error;
+ }
+ HDclose(connfd);
+ } /* end if "CONFIRM" directive */
else if (H5FD_MIRROR_XMIT_OPEN_SIZE == ret) {
H5FD_mirror_xmit_open_t xopen;
diff --git a/utils/mirror_vfd/mirror_server_stop.c b/utils/mirror_vfd/mirror_server_stop.c
index 024b33a..44386bf 100644
--- a/utils/mirror_vfd/mirror_server_stop.c
+++ b/utils/mirror_vfd/mirror_server_stop.c
@@ -60,7 +60,7 @@ struct mshs_opts {
static void
usage(void)
{
- HDprintf("mirror_server_halten_sie [options]\n"
+ HDprintf("mirror_server_stop [options]\n"
"System-independent Mirror Server shutdown program.\n"
"Sends shutdown message to Mirror Server at given IP:port\n"
"\n"
@@ -128,6 +128,7 @@ parse_args(int argc, char **argv, struct mshs_opts *opts)
static int
send_shutdown(struct mshs_opts *opts)
{
+ char mybuf[16];
int live_socket;
struct sockaddr_in target_addr;
@@ -157,6 +158,16 @@ send_shutdown(struct mshs_opts *opts)
return -1;
}
+ /* Read & verify response from port connection. */
+ if (HDread(live_socket, &mybuf, sizeof(mybuf)) == -1) {
+ HDprintf("ERROR read() can't receive data\n");
+ return -1;
+ }
+ if (HDstrncmp("CLOSING", mybuf, 8)) {
+ HDprintf("ERROR read() didn't receive data from server\n");
+ return -1;
+ }
+
if (HDclose(live_socket) < 0) {
HDprintf("ERROR close() can't close socket\n");
return -1;