Skip to content

Commit

Permalink
Merge pull request #119 from grondo/lgtm-fixes
Browse files Browse the repository at this point in the history
minor fixes and enhancements for next release
  • Loading branch information
garlick committed Jan 7, 2020
2 parents 7f2cc72 + d161874 commit 3f7e40f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 21 deletions.
8 changes: 8 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
This file describes changes in recent versions of pdsh. It primarily
documents those changes that are of interest to users and admins.

* Changes in pdsh-2.34 (2020-01-07)
===================================
-- Fix for output corruption with no newlines (#114)
-- pipecmd: fix result check error handling (Dylan Simon)
-- slurm: workaround slurm export of internal List interfaces
-- readline: add application name as argv[0] (#112)
-- Fix errors from lgtm.com scan

* Changes in pdsh-2.33 (2017-06-28)
===================================
-- Fix segfault and build issues on Mac OSX (#95)
Expand Down
2 changes: 1 addition & 1 deletion pdsh.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: pdsh
Version: 2.33
Version: 2.34
Release: 1

Summary: Parallel remote shell program
Expand Down
2 changes: 1 addition & 1 deletion src/common/hostlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -2145,7 +2145,7 @@ _get_bracketed_list(hostlist_t hl, int *start, const size_t n, char *buf)
if ((len < 0) || (len > n))
return n; /* truncated, buffer filled */

if (bracket_needed && len < n && len >= 0)
if (bracket_needed && len < n)
buf[len++] = '[';

do {
Expand Down
5 changes: 5 additions & 0 deletions src/modules/slurm.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@
/*
* SLURM headers need to be included after pdsh header files to
* avoid possibly conflicts with the definition of "bool"
*
* Also, Slurm inexplicably exports the "list.h" interface in slurm.h,
* and we must define __list_datatypes_defined here to avoid conflict
* with our internal List datatype.
*/
#define __list_datatypes_defined 1
#include <slurm/slurm.h>
#include <slurm/slurm_errno.h>

Expand Down
36 changes: 18 additions & 18 deletions src/pdsh/dsh.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,19 +270,19 @@ static void _fwd_signal(int signum)

}

static int _thd_connect_timeout (thd_t *t)
static int _thd_connect_timeout (thd_t *th)
{
if ((connect_timeout > 0) && (t->start != ((time_t) -1))) {
if (t->start + connect_timeout < time (NULL))
if ((connect_timeout > 0) && (th->start != ((time_t) -1))) {
if (th->start + connect_timeout < time (NULL))
return (1);
}
return (0);
}

static int _thd_command_timeout (thd_t *t)
static int _thd_command_timeout (thd_t *th)
{
if ((command_timeout > 0) && (t->connect != ((time_t) -1))) {
if (t->connect + command_timeout < time (NULL))
if ((command_timeout > 0) && (th->connect != ((time_t) -1))) {
if (th->connect + command_timeout < time (NULL))
return (1);
}
return (0);
Expand Down Expand Up @@ -519,7 +519,7 @@ static int _extract_rc(char *buf)
return ret;
}

static void _flush_lines (cbuf_t cb, out_f outf, bool read_rc, thd_t *t)
static void _flush_lines (cbuf_t cb, out_f outf, bool read_rc, thd_t *th)
{
char c;
int n;
Expand All @@ -532,7 +532,7 @@ static void _flush_lines (cbuf_t cb, out_f outf, bool read_rc, thd_t *t)
char *buf;

if (n < 0) {
err ("%p: %S: Failed to peek line: %m\n", t->host);
err ("%p: %S: Failed to peek line: %m\n", th->host);
break;
}

Expand All @@ -543,19 +543,19 @@ static void _flush_lines (cbuf_t cb, out_f outf, bool read_rc, thd_t *t)
buf = Malloc (n + 1);
if ((n = cbuf_read (cb, buf, n))) {
if (n < 0) {
err ("%p: %S: Failed to read line from buffer: %m\n", t->host);
err ("%p: %S: Failed to read line from buffer: %m\n", th->host);
break;
}
if (read_rc)
t->rc = _extract_rc (buf);
th->rc = _extract_rc (buf);
if (strlen (buf) > 0) {
/*
* We are careful to use a single call to write the line
* to the output stream to avoid interleaved lines of
* output.
*/
if (t->labels)
outf ("%S: %s", t->host, buf);
if (th->labels)
outf ("%S: %s", th->host, buf);
else
outf ("%s", buf);
fflush (NULL);
Expand Down Expand Up @@ -583,7 +583,7 @@ static int _do_output (int fd, cbuf_t cb, out_f outf, bool read_rc, thd_t *t)
return (rc);
}

static void _flush_output (cbuf_t cb, out_f outf, thd_t *t)
static void _flush_output (cbuf_t cb, out_f outf, thd_t *th)
{
int n;
bool labeled = false;
Expand All @@ -594,8 +594,8 @@ static void _flush_output (cbuf_t cb, out_f outf, thd_t *t)
/* In case no newline at end of buffer, grab the rest of data */
while ((n = cbuf_read (cb, buf, sizeof (buf) - 1)) > 0) {
buf[n] = '\0';
if (t->labels && !labeled) {
outf ("%S: ", t->host);
if (th->labels && !labeled) {
outf ("%S: ", th->host);
labeled = true;
}
outf ("%s", buf);
Expand All @@ -604,14 +604,14 @@ static void _flush_output (cbuf_t cb, out_f outf, thd_t *t)
return;
}

static int _die_if_signalled (thd_t *t)
static int _die_if_signalled (thd_t *th)
{
int sig;

if ((sig = (t->rc - 128)) <= 0)
if ((sig = (th->rc - 128)) <= 0)
return (0);

err ("%p: process on host %S killed by signal %d\n", t->host, sig);
err ("%p: process on host %S killed by signal %d\n", th->host, sig);
_fwd_signal (SIGTERM);
errx ("%p: terminating all processes.\n");

Expand Down
6 changes: 5 additions & 1 deletion src/pdsh/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,16 @@ int main(int argc, char *argv[])
opt_t opt;
int retval = 0;
const char *m;
char *prog = xbasename(argv[0]);

#if HAVE_READLINE
rl_readline_name = prog;
#endif

/*
* Initialize.
*/
err_init(xbasename(argv[0])); /* init err package */
err_init(prog); /* init err package */

/*
* If running setuid, fork a child to handle
Expand Down

0 comments on commit 3f7e40f

Please sign in to comment.