Oess 168 utils mirror vfd (#1444)

* Committing clang-format changes

* Spelling of preceed was corrected to proceed, but should have been
corrected to precede.

* Correct spelling correction of 'preceed' incorrectly to 'proceed'.  It should be 'precede'.

* OESS-168: Remove clang warnings.

* OESS-168: Address @lrknox and @gnuoyd reviews.

* Eliminate clang warnings listed in PR #1310 without adding new ssize_t
variables.

* Committing clang-format changes

* Add H5_ATTR_UNUSED to wait_for_child call.
Remove unneeded casts in mirror_log calls.

* Keep ssize_t in mirror_server.c line 479.

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Hyo-Kyung Lee <hyoklee@hdfgroup.org>
This commit is contained in:
Larry Knox 2022-02-21 15:32:29 -06:00 committed by GitHub
parent c302773438
commit 3107fafa2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 23 deletions

View File

@ -28,10 +28,10 @@ extern "C" {
* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
*/
/* The maximum allowed size for a receiving buffer when accepting bytes to
/* Define the maximum allowed size for a receiving buffer when accepting bytes to
* write. Writes larger than this size are performed by multiple accept-write
* steps by the Writer. */
#define H5FD_MIRROR_DATA_BUFFER_MAX H5_GB /* 1 Gigabyte */
#define H5FD_MIRROR_DATA_BUFFER_MAX (1024 * 1024 * 1024) /* 1 Gigabyte */
#define H5FD_MIRROR_XMIT_CURR_VERSION 1
#define H5FD_MIRROR_XMIT_MAGIC 0x87F8005B

View File

@ -147,7 +147,7 @@ mirror_log_bytes(struct mirror_log_info *info, unsigned int level, size_t n_byte
* ----------------------------------------------------------------------------
*/
loginfo_t *
mirror_log_init(char *path, char *prefix, unsigned int verbosity)
mirror_log_init(char *path, const char *prefix, unsigned int verbosity)
{
loginfo_t *info = NULL;

View File

@ -42,7 +42,7 @@ typedef struct mirror_log_info {
void mirror_log(loginfo_t *info, unsigned int level, const char *format, ...);
void mirror_log_bytes(loginfo_t *info, unsigned int level, size_t n_bytes, const unsigned char *buf);
loginfo_t *mirror_log_init(char *path, char *prefix, unsigned int verbosity);
loginfo_t *mirror_log_init(char *path, const char *prefix, unsigned int verbosity);
int mirror_log_term(loginfo_t *loginfo);
herr_t run_writer(int socketfd, H5FD_mirror_xmit_open_t *xmit_open);

View File

@ -94,14 +94,14 @@
* ---------------------------------------------------------------------------
*/
struct op_args {
uint32_t magic;
int help;
int main_port;
int verbosity;
int log_prepend_serv;
int log_prepend_type;
char log_path[PATH_MAX + 1];
char writer_log_path[PATH_MAX + 1];
uint32_t magic;
int help;
int main_port;
unsigned int verbosity;
int log_prepend_serv;
int log_prepend_type;
char log_path[PATH_MAX + 1];
char writer_log_path[PATH_MAX + 1];
};
/* ---------------------------------------------------------------------------
@ -224,7 +224,7 @@ parse_args(int argc, char **argv, struct op_args *args_out)
} /* end if port */
else if (!HDstrncmp(argv[i], "--verbosity=", 12)) {
mirror_log(NULL, V_INFO, "parsing 'verbosity' (%s)", argv[i] + 12);
args_out->verbosity = HDatoi(argv[i] + 12);
args_out->verbosity = (unsigned int)HDatoi(argv[i] + 12);
} /* end if verbosity */
else if (!HDstrncmp(argv[i], "--logpath=", 10)) {
mirror_log(NULL, V_INFO, "parsing 'logpath' (%s)", argv[i] + 10);
@ -456,7 +456,7 @@ error:
* ---------------------------------------------------------------------------
*/
static void
wait_for_child(int sig)
wait_for_child(int H5_ATTR_UNUSED sig)
{
while (HDwaitpid(-1, NULL, WNOHANG) > 0)
;
@ -476,7 +476,7 @@ handle_requests(struct server_run *run)
{
int connfd = -1; /**/
char mybuf[H5FD_MIRROR_XMIT_OPEN_SIZE]; /**/
int ret; /* general-purpose error-checking */
ssize_t ret; /* general-purpose error-checking */
int pid; /* process ID of fork */
struct sigaction sa;
int ret_value = 0;
@ -521,14 +521,13 @@ handle_requests(struct server_run *run)
/* Read handshake from port connection.
*/
ret = (int)HDread(connfd, &mybuf, H5FD_MIRROR_XMIT_OPEN_SIZE);
if (-1 == ret) {
if ((ret = HDread(connfd, &mybuf, H5FD_MIRROR_XMIT_OPEN_SIZE)) < 0) {
mirror_log(run->loginfo, V_ERR, "read:%d", ret);
goto error;
}
mirror_log(run->loginfo, V_INFO, "received %d bytes", ret);
mirror_log(run->loginfo, V_ALL, "```");
mirror_log_bytes(run->loginfo, V_ALL, ret, (const unsigned char *)mybuf);
mirror_log_bytes(run->loginfo, V_ALL, (size_t)ret, (const unsigned char *)mybuf);
mirror_log(run->loginfo, V_ALL, "```");
/* Respond to handshake message.

View File

@ -788,8 +788,7 @@ do_write(struct mirror_session *session, const unsigned char *xmit_buf)
*/
sum_bytes_written = 0;
do {
nbytes_in_packet = HDread(session->sockfd, buf, H5FD_MIRROR_DATA_BUFFER_MAX);
if (-1 == nbytes_in_packet) {
if ((nbytes_in_packet = HDread(session->sockfd, buf, H5FD_MIRROR_DATA_BUFFER_MAX)) < 0) {
mirror_log(session->loginfo, V_ERR, "can't read into databuffer");
reply_error(session, "can't read data buffer");
return -1;
@ -798,7 +797,7 @@ do_write(struct mirror_session *session, const unsigned char *xmit_buf)
mirror_log(session->loginfo, V_INFO, "received %zd bytes", nbytes_in_packet);
if (HEXDUMP_WRITEDATA) {
mirror_log(session->loginfo, V_ALL, "DATA:\n```");
mirror_log_bytes(session->loginfo, V_ALL, nbytes_in_packet, (const unsigned char *)buf);
mirror_log_bytes(session->loginfo, V_ALL, (size_t)nbytes_in_packet, (const unsigned char *)buf);
mirror_log(session->loginfo, V_ALL, "```");
}
@ -859,8 +858,7 @@ receive_communique(struct mirror_session *session, struct sock_comm *comm)
mirror_log(session->loginfo, V_INFO, "ready to receive"); /* TODO */
read_ret = HDread(session->sockfd, comm->raw, H5FD_MIRROR_XMIT_BUFFER_MAX);
if (-1 == read_ret) {
if ((read_ret = HDread(session->sockfd, comm->raw, H5FD_MIRROR_XMIT_BUFFER_MAX)) < 0) {
mirror_log(session->loginfo, V_ERR, "read:%zd", read_ret);
goto error;
}