Brings mirror VFD test fixes from develop (#2392)

This commit is contained in:
Dana Robinson 2023-01-05 12:51:25 -08:00 committed by GitHub
parent 363b26fa0d
commit cedd2a41f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1626 additions and 1712 deletions

View File

@ -244,7 +244,7 @@ H5FD_mirror_init(void)
FUNC_ENTER_NOAPI(H5I_INVALID_HID)
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
if (H5I_VFL != H5I_get_type(H5FD_MIRROR_g)) {
H5FD_MIRROR_g = H5FD_register(&H5FD_mirror_g, sizeof(H5FD_class_t), FALSE);
@ -268,12 +268,12 @@ done:
static herr_t
H5FD__mirror_term(void)
{
FUNC_ENTER_STATIC_NOERR
FUNC_ENTER_PACKAGE_NOERR
/* Reset VFL ID */
H5FD_MIRROR_g = 0;
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5FD__mirror_term() */
@ -337,7 +337,7 @@ H5FD__mirror_xmit_decode_uint32(uint32_t *out, const unsigned char *_buf)
/* ---------------------------------------------------------------------------
* Function: is_host_little_endian
*
* Purpose: Determine whether the host machine is is little-endian.
* Purpose: Determine whether the host machine is little-endian.
*
* Store an integer with a known value, re-map the memory to a
* character array, and inspect the array's contents.
@ -1127,9 +1127,9 @@ H5FD__mirror_verify_reply(H5FD_mirror_t *file)
ssize_t read_ret = 0;
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
FUNC_ENTER_PACKAGE
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
HDassert(file && file->sock_fd);
@ -1182,9 +1182,9 @@ H5FD__mirror_fapl_get(H5FD_t *_file)
H5FD_mirror_fapl_t *fa = NULL;
void *ret_value = NULL;
FUNC_ENTER_STATIC
FUNC_ENTER_PACKAGE
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
fa = (H5FD_mirror_fapl_t *)H5MM_calloc(sizeof(H5FD_mirror_fapl_t));
if (NULL == fa)
@ -1218,9 +1218,9 @@ H5FD__mirror_fapl_copy(const void *_old_fa)
H5FD_mirror_fapl_t *new_fa = NULL;
void *ret_value = NULL;
FUNC_ENTER_STATIC
FUNC_ENTER_PACKAGE
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
new_fa = (H5FD_mirror_fapl_t *)H5MM_malloc(sizeof(H5FD_mirror_fapl_t));
if (new_fa == NULL)
@ -1250,9 +1250,9 @@ H5FD__mirror_fapl_free(void *_fa)
{
H5FD_mirror_fapl_t *fa = (H5FD_mirror_fapl_t *)_fa;
FUNC_ENTER_STATIC_NOERR
FUNC_ENTER_PACKAGE_NOERR
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
/* sanity check */
HDassert(fa != NULL);
@ -1283,7 +1283,7 @@ H5Pget_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa_dst)
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*x", fapl_id, fa_dst);
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
if (NULL == fa_dst)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "fa_dst is NULL");
@ -1324,7 +1324,7 @@ H5Pset_fapl_mirror(hid_t fapl_id, H5FD_mirror_fapl_t *fa)
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*x", fapl_id, fa);
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS);
if (NULL == plist)
@ -1368,9 +1368,9 @@ H5FD__mirror_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxad
H5FD_mirror_xmit_open_t *open_xmit = NULL;
H5FD_t *ret_value = NULL;
FUNC_ENTER_STATIC
FUNC_ENTER_PACKAGE
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
/* --------------- */
/* Check arguments */
@ -1493,9 +1493,9 @@ H5FD__mirror_close(H5FD_t *_file)
int xmit_encoded = 0; /* monitor point of failure */
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
FUNC_ENTER_PACKAGE
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
/* Sanity check */
HDassert(file);
@ -1565,9 +1565,9 @@ done:
static herr_t
H5FD__mirror_query(const H5FD_t H5_ATTR_UNUSED *_file, unsigned long *flags)
{
FUNC_ENTER_STATIC_NOERR;
FUNC_ENTER_PACKAGE_NOERR;
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
/* Notice: the Mirror VFD Writer currently uses only the Sec2 driver as
* the underlying driver -- as such, the Mirror VFD implementation copies
@ -1602,9 +1602,9 @@ H5FD__mirror_get_eoa(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type)
{
const H5FD_mirror_t *file = (const H5FD_mirror_t *)_file;
FUNC_ENTER_STATIC_NOERR
FUNC_ENTER_PACKAGE_NOERR
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
HDassert(file);
@ -1629,9 +1629,9 @@ H5FD__mirror_set_eoa(H5FD_t *_file, H5FD_mem_t type, haddr_t addr)
H5FD_mirror_t *file = (H5FD_mirror_t *)_file;
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
FUNC_ENTER_PACKAGE
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
HDassert(file);
@ -1684,9 +1684,9 @@ H5FD__mirror_get_eof(const H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type)
{
const H5FD_mirror_t *file = (const H5FD_mirror_t *)_file;
FUNC_ENTER_STATIC_NOERR
FUNC_ENTER_PACKAGE_NOERR
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
HDassert(file);
@ -1705,9 +1705,9 @@ static herr_t
H5FD__mirror_read(H5FD_t H5_ATTR_UNUSED *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t H5_ATTR_UNUSED fapl_id,
haddr_t H5_ATTR_UNUSED addr, size_t H5_ATTR_UNUSED size, void H5_ATTR_UNUSED *buf)
{
FUNC_ENTER_STATIC_NOERR
FUNC_ENTER_PACKAGE_NOERR
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
FUNC_LEAVE_NOAPI(FAIL)
} /* end H5FD__mirror_read() */
@ -1738,9 +1738,9 @@ H5FD__mirror_write(H5FD_t *_file, H5FD_mem_t type, hid_t H5_ATTR_UNUSED dxpl_id,
H5FD_mirror_t *file = (H5FD_mirror_t *)_file;
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
FUNC_ENTER_PACKAGE
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
HDassert(file);
HDassert(buf);
@ -1801,9 +1801,9 @@ H5FD__mirror_truncate(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, hbool_t H5_AT
H5FD_mirror_t *file = (H5FD_mirror_t *)_file;
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
FUNC_ENTER_PACKAGE
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
file->xmit.xmit_count = (file->xmit_i)++;
file->xmit.op = H5FD_MIRROR_OP_TRUNCATE;
@ -1849,9 +1849,9 @@ H5FD__mirror_lock(H5FD_t *_file, hbool_t rw)
H5FD_mirror_t *file = (H5FD_mirror_t *)_file;
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
FUNC_ENTER_PACKAGE
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
file->xmit.xmit_count = (file->xmit_i)++;
file->xmit.op = H5FD_MIRROR_OP_LOCK;
@ -1896,9 +1896,9 @@ H5FD__mirror_unlock(H5FD_t *_file)
H5FD_mirror_t *file = (H5FD_mirror_t *)_file;
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
FUNC_ENTER_PACKAGE
LOG_OP_CALL(FUNC);
LOG_OP_CALL(__func__);
file->xmit.xmit_count = (file->xmit_i)++;
file->xmit.op = H5FD_MIRROR_OP_UNLOCK;

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,10 @@
nerrors=0
SERVER_VERBOSITY="--verbosity=1"
SERVER_PORT="--port=3000"
# Choose random ephemeral port number
RANDOM_PORT=$[ $RANDOM % 16384 + 49152 ]
echo "Using port: $RANDOM_PORT"
SERVER_PORT="--port=$RANDOM_PORT"
###############################################################################
@ -45,7 +48,9 @@ done
RUN_DIR=mirror_vfd_test
MIRROR_UTILS=../utils/mirror_vfd # TODO: presupposes from test/
mkdir $RUN_DIR
if [[ ! -d $RUN_DIR ]] ; then
mkdir $RUN_DIR
fi
# Copy program files into dedicated test directory
for FILE in $MIRROR_UTILS/mirror_* ; do
@ -61,6 +66,10 @@ cp mirror_vfd $RUN_DIR
# wrapper script. Copy these libs builds if appropriate.
if [ -f $MIRROR_UTILS/.libs/mirror_server ] ; then
RUN_LIBS=$RUN_DIR/.libs
# Delete previous .libs directory, to remove any generated libtool files
if [[ -d $RUN_LIBS ]] ; then
rm -rf $RUN_LIBS
fi
mkdir $RUN_LIBS
for FILE in $MIRROR_UTILS/.libs/mirror_* ; do
case "$FILE" in
@ -77,12 +86,15 @@ echo "Launching Mirror Server"
SERVER_ARGS="$SERVER_PORT $SERVER_VERBOSITY"
./mirror_server $SERVER_ARGS &
./mirror_vfd
./mirror_vfd $SERVER_PORT
nerrors=$?
echo "Stopping Mirror Server"
./mirror_server_stop $SERVER_PORT
# Wait for background server process to exit
wait
###############################################################################
## Report and exit
###############################################################################

View File

@ -139,7 +139,7 @@ setup_parameters(int argc, char *const argv[], options_t *opts)
opts->nplanes = (hsize_t)opts->chunksize;
show_parameters(opts);
return (0);
return 0;
} /* setup_parameters() */
/* Overall Algorithm:
@ -152,17 +152,17 @@ setup_parameters(int argc, char *const argv[], options_t *opts)
int
main(int argc, char *argv[])
{
pid_t childpid = 0;
pid_t mypid, tmppid;
int child_status;
int child_wait_option = 0;
int ret_value = 0;
int child_ret_value;
hbool_t send_wait = FALSE;
hid_t fid = -1; /* File ID */
H5FD_mirror_fapl_t mirr_fa;
H5FD_splitter_vfd_config_t split_fa;
hid_t mirr_fapl_id = H5I_INVALID_HID;
pid_t childpid = 0;
pid_t mypid, tmppid;
int child_status;
int child_wait_option = 0;
int ret_value = 0;
int child_ret_value;
hbool_t send_wait = FALSE;
hid_t fid = H5I_INVALID_HID;
H5FD_mirror_fapl_t mirr_fa;
H5FD_splitter_vfd_config_t *split_fa = NULL;
hid_t mirr_fapl_id = H5I_INVALID_HID;
if (setup_parameters(argc, argv, &UC_opts) < 0) {
Hgoto_error(1);
@ -173,13 +173,18 @@ main(int argc, char *argv[])
mirr_fa.handshake_port = SERVER_PORT;
HDstrncpy(mirr_fa.remote_ip, SERVER_IP, H5FD_MIRROR_MAX_IP_LEN);
split_fa.wo_fapl_id = H5I_INVALID_HID;
split_fa.rw_fapl_id = H5I_INVALID_HID;
split_fa.magic = H5FD_SPLITTER_MAGIC;
split_fa.version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION;
split_fa.log_file_path[0] = '\0'; /* none */
split_fa.ignore_wo_errs = FALSE;
HDstrncpy(split_fa.wo_path, MIRROR_FILE_NAME, H5FD_SPLITTER_PATH_MAX);
if (NULL == (split_fa = HDcalloc(1, sizeof(H5FD_splitter_vfd_config_t)))) {
HDfprintf(stderr, "can't allocate memory for splitter config\n");
Hgoto_error(1);
}
split_fa->wo_fapl_id = H5I_INVALID_HID;
split_fa->rw_fapl_id = H5I_INVALID_HID;
split_fa->magic = H5FD_SPLITTER_MAGIC;
split_fa->version = H5FD_CURR_SPLITTER_VFD_CONFIG_VERSION;
split_fa->log_file_path[0] = '\0'; /* none */
split_fa->ignore_wo_errs = FALSE;
HDstrncpy(split_fa->wo_path, MIRROR_FILE_NAME, H5FD_SPLITTER_PATH_MAX);
/* Determine the need to send/wait message file*/
if (UC_opts.launch == UC_READWRITE) {
@ -211,14 +216,14 @@ main(int argc, char *argv[])
}
/* Prepare parent "splitter" driver in UC_opts */
split_fa.wo_fapl_id = mirr_fapl_id;
split_fa.rw_fapl_id = H5P_DEFAULT;
UC_opts.fapl_id = H5Pcreate(H5P_FILE_ACCESS);
split_fa->wo_fapl_id = mirr_fapl_id;
split_fa->rw_fapl_id = H5P_DEFAULT;
UC_opts.fapl_id = H5Pcreate(H5P_FILE_ACCESS);
if (UC_opts.fapl_id == H5I_INVALID_HID) {
HDfprintf(stderr, "can't create creation FAPL\n");
Hgoto_error(1);
}
if (H5Pset_fapl_splitter(UC_opts.fapl_id, &split_fa) < 0) {
if (H5Pset_fapl_splitter(UC_opts.fapl_id, split_fa) < 0) {
HDfprintf(stderr, "can't set creation FAPL\n");
H5Eprint2(H5E_DEFAULT, stdout);
Hgoto_error(1);
@ -300,14 +305,14 @@ main(int argc, char *argv[])
}
/* Prepare parent "splitter" driver in UC_opts */
split_fa.wo_fapl_id = mirr_fapl_id;
split_fa.rw_fapl_id = H5P_DEFAULT;
UC_opts.fapl_id = H5Pcreate(H5P_FILE_ACCESS);
split_fa->wo_fapl_id = mirr_fapl_id;
split_fa->rw_fapl_id = H5P_DEFAULT;
UC_opts.fapl_id = H5Pcreate(H5P_FILE_ACCESS);
if (UC_opts.fapl_id == H5I_INVALID_HID) {
HDfprintf(stderr, "can't create creation FAPL\n");
Hgoto_error(1);
}
if (H5Pset_fapl_splitter(UC_opts.fapl_id, &split_fa) < 0) {
if (H5Pset_fapl_splitter(UC_opts.fapl_id, split_fa) < 0) {
HDfprintf(stderr, "can't set creation FAPL\n");
H5Eprint2(H5E_DEFAULT, stdout);
Hgoto_error(1);
@ -368,6 +373,8 @@ main(int argc, char *argv[])
}
done:
HDfree(split_fa);
if (ret_value != 0) {
HDprintf("Error(s) encountered\n");
}
@ -375,7 +382,7 @@ done:
HDprintf("All passed\n");
}
return (ret_value);
return ret_value;
}
#else /* H5_HAVE_MIRROR_VFD */

View File

@ -12,7 +12,7 @@ set (mirror_server_SOURCES
${HDF5_UTILS_MIRRORVFD_SOURCE_DIR}/mirror_remote.h
)
add_executable (mirror_server ${mirror_server_SOURCES})
target_include_directories (mirror_server PRIVATE "${HDF5_UITLS_DIR};${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
target_include_directories (mirror_server PRIVATE "${HDF5_UTILS_DIR};${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
if (NOT BUILD_SHARED_LIBS)
TARGET_C_PROPERTIES (mirror_server STATIC)
target_link_libraries (mirror_server PRIVATE ${HDF5_LIB_TARGET})
@ -37,7 +37,7 @@ endif ()
set (mirror_server_stop_SOURCES ${HDF5_UTILS_MIRRORVFD_SOURCE_DIR}/mirror_server_stop.c)
add_executable (mirror_server_stop ${mirror_server_stop_SOURCES})
target_include_directories (mirror_server_stop PRIVATE "${HDF5_UITLS_DIR};${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
target_include_directories (mirror_server_stop PRIVATE "${HDF5_UTILS_DIR};${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
if (NOT BUILD_SHARED_LIBS)
TARGET_C_PROPERTIES (mirror_server_stop STATIC)
target_link_libraries (mirror_server_stop PRIVATE ${HDF5_LIB_TARGET})

View File

@ -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;
@ -474,12 +471,13 @@ wait_for_child(int H5_ATTR_UNUSED sig)
static int
handle_requests(struct server_run *run)
{
int connfd = -1; /**/
char mybuf[H5FD_MIRROR_XMIT_OPEN_SIZE]; /**/
ssize_t ret; /* general-purpose error-checking */
int pid; /* process ID of fork */
struct sigaction sa;
int ret_value = 0;
int connfd = -1;
char *mybuf = NULL;
ssize_t ret; /* general-purpose error-checking */
int pid; /* process ID of fork */
struct sigaction sa;
H5FD_mirror_xmit_open_t *xopen = NULL;
int ret_value = 0;
if (run == NULL || run->magic != SERVER_RUN_MAGIC) {
mirror_log(NULL, V_ERR, "invalid server_run pointer");
@ -504,6 +502,15 @@ handle_requests(struct server_run *run)
return 1;
}
if (NULL == (mybuf = HDmalloc(H5FD_MIRROR_XMIT_OPEN_SIZE * sizeof(char)))) {
mirror_log(NULL, V_ERR, "out of memory");
goto error;
}
if (NULL == (xopen = HDmalloc(sizeof(H5FD_mirror_xmit_open_t)))) {
mirror_log(NULL, V_ERR, "out of memory");
goto error;
}
/* Keep listening for attempts to connect.
*/
@ -521,7 +528,7 @@ handle_requests(struct server_run *run)
/* Read handshake from port connection.
*/
if ((ret = HDread(connfd, &mybuf, H5FD_MIRROR_XMIT_OPEN_SIZE)) < 0) {
if ((ret = HDread(connfd, mybuf, H5FD_MIRROR_XMIT_OPEN_SIZE)) < 0) {
mirror_log(run->loginfo, V_ERR, "read:%d", ret);
goto error;
}
@ -536,17 +543,33 @@ 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;
mirror_log(run->loginfo, V_INFO, "probable OPEN xmit received");
H5FD_mirror_xmit_decode_open(&xopen, (const unsigned char *)mybuf);
if (FALSE == H5FD_mirror_xmit_is_open(&xopen)) {
H5FD_mirror_xmit_decode_open(xopen, (const unsigned char *)mybuf);
if (FALSE == H5FD_mirror_xmit_is_open(xopen)) {
mirror_log(run->loginfo, V_WARN, "expected OPEN xmit was malformed");
HDclose(connfd);
continue;
@ -561,7 +584,7 @@ handle_requests(struct server_run *run)
} /* end if fork error */
else if (pid == 0) { /* child process (writer side of fork) */
mirror_log(run->loginfo, V_INFO, "executing writer");
if (run_writer(connfd, &xopen) < 0) {
if (run_writer(connfd, xopen) < 0) {
HDprintf("can't run writer\n");
}
else {
@ -591,12 +614,17 @@ done:
HDclose(connfd);
}
HDfree(mybuf);
HDfree(xopen);
return ret_value;
error:
if (connfd >= 0) {
HDclose(connfd);
}
HDfree(mybuf);
HDfree(xopen);
return -1;
} /* end handle_requests() */

View File

@ -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;

View File

@ -929,25 +929,33 @@ static int
process_instructions(struct mirror_session *session)
{
struct sock_comm comm;
char xmit_buf[H5FD_MIRROR_XMIT_BUFFER_MAX]; /* raw bytes */
H5FD_mirror_xmit_t xmit_recd; /* for decoded xmit header */
char *xmit_buf = NULL; /* raw bytes */
size_t buf_size;
H5FD_mirror_xmit_t xmit_recd; /* for decoded xmit header */
HDassert(session && (session->magic == MW_SESSION_MAGIC));
mirror_log(session->loginfo, V_INFO, "process_instructions()");
buf_size = H5FD_MIRROR_XMIT_BUFFER_MAX * sizeof(char);
if (NULL == (xmit_buf = HDmalloc(buf_size))) {
mirror_log(session->loginfo, V_ERR, "out of memory");
goto error;
}
comm.magic = MW_SOCK_COMM_MAGIC;
comm.recd_die = 0; /* Flag for program to terminate */
comm.xmit_recd = &xmit_recd;
comm.raw = xmit_buf;
comm.raw_size = sizeof(xmit_buf);
comm.raw_size = buf_size;
while (1) { /* sill-listening infinite loop */
/* Use convenience structure for raw/decoded info in/out */
if (receive_communique(session, &comm) < 0) {
mirror_log(session->loginfo, V_ERR, "problem reading socket");
return -1;
goto error;
}
if (comm.recd_die) {
@ -957,42 +965,42 @@ process_instructions(struct mirror_session *session)
switch (xmit_recd.op) {
case H5FD_MIRROR_OP_CLOSE:
if (do_close(session) < 0) {
return -1;
goto error;
}
goto done;
case H5FD_MIRROR_OP_LOCK:
if (do_lock(session, (const unsigned char *)xmit_buf) < 0) {
return -1;
goto error;
}
break;
case H5FD_MIRROR_OP_OPEN:
mirror_log(session->loginfo, V_ERR, "OPEN xmit during session");
reply_error(session, "illegal OPEN xmit during session");
return -1;
goto error;
case H5FD_MIRROR_OP_SET_EOA:
if (do_set_eoa(session, (const unsigned char *)xmit_buf) < 0) {
return -1;
goto error;
}
break;
case H5FD_MIRROR_OP_TRUNCATE:
if (do_truncate(session) < 0) {
return -1;
goto error;
}
break;
case H5FD_MIRROR_OP_UNLOCK:
if (do_unlock(session) < 0) {
return -1;
goto error;
}
break;
case H5FD_MIRROR_OP_WRITE:
if (do_write(session, (const unsigned char *)xmit_buf) < 0) {
return -1;
goto error;
}
break;
default:
mirror_log(session->loginfo, V_ERR, "unrecognized transmission");
reply_error(session, "unrecognized transmission");
return -1;
goto error;
} /* end switch (xmit_recd.op) */
} /* end while still listening */
@ -1000,7 +1008,12 @@ process_instructions(struct mirror_session *session)
done:
comm.magic = 0; /* invalidate structure, on principle */
xmit_recd.magic = 0; /* invalidate structure, on principle */
HDfree(xmit_buf);
return 0;
error:
HDfree(xmit_buf);
return -1;
} /* end process_instructions() */
/* ---------------------------------------------------------------------------