Skip to content

Commit

Permalink
Merge pull request #1629 from chu11/misccleanup12
Browse files Browse the repository at this point in the history
minor fixes and enhancements
  • Loading branch information
grondo committed Aug 24, 2018
2 parents 4a2674b + ca70740 commit 72a0550
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/broker/broker.c
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ static void cmb_event_mute_cb (flux_t *h, flux_msg_handler_t *mh,
static void cmb_disconnect_cb (flux_t *h, flux_msg_handler_t *mh,
const flux_msg_t *msg, void *arg)
{
char *sender = NULL;;
char *sender = NULL;

if (flux_msg_get_route_first (msg, &sender) == 0) {
exec_terminate_subprocesses_by_uuid (h, sender);
Expand Down
4 changes: 3 additions & 1 deletion src/common/libflux/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct flux_buffer {
int size;
bool readonly;
cbuf_t cbuf;
void *buf; /* internal buffer for user reads */
char *buf; /* internal buffer for user reads */
int buflen;
int cb_type;
flux_buffer_cb cb;
Expand Down Expand Up @@ -340,6 +340,7 @@ const void *flux_buffer_peek (flux_buffer_t *fb, int len, int *lenp)

if ((ret = cbuf_peek (fb->cbuf, fb->buf, len)) < 0)
return NULL;
fb->buf[ret] = '\0';

if (lenp)
(*lenp) = ret;
Expand All @@ -364,6 +365,7 @@ const void *flux_buffer_read (flux_buffer_t *fb, int len, int *lenp)

if ((ret = cbuf_read (fb->cbuf, fb->buf, len)) < 0)
return NULL;
fb->buf[ret] = '\0';

if (lenp)
(*lenp) = ret;
Expand Down
15 changes: 9 additions & 6 deletions src/common/libflux/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,20 @@ int flux_buffer_drop (flux_buffer_t *fb, int len);

/* Read up to [len] bytes of data in the buffer without consuming it.
* Pointer to buffer is returned to user and optionally length read
* can be returned to user in [lenp]. User shall not free returned
* pointer. If no data is available, returns pointer and length of 0.
* Set [len] to -1 to read all data.
* can be returned to user in [lenp]. The buffer will always be NUL
* terminated, so the user may treat returned ptr as a string. User
* shall not free returned pointer. If no data is available, returns
* pointer and length of 0. Set [len] to -1 to read all data.
*/
const void *flux_buffer_peek (flux_buffer_t *fb, int len, int *lenp);

/* Read up to [len] bytes of data in the buffer and mark data as
* consumed. Pointer to buffer is returned to user and optionally
* length read can be returned to user in [lenp]. User shall not free
* returned pointer. If no data is available, returns pointer and
* length of 0. Set [len] to -1 to read all data.
* length read can be returned to user in [lenp]. The buffer will
* always be NUL terminated, so the user may treat returned ptr as a
* string. User shall not free returned pointer. If no data is
* available, returns pointer and length of 0. Set [len] to -1 to
* read all data.
*/
const void *flux_buffer_read (flux_buffer_t *fb, int len, int *lenp);

Expand Down
4 changes: 2 additions & 2 deletions src/modules/cron/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static int state_handler (flux_t *h, cron_task_t *t, const flux_msg_t *msg)
static void cron_task_rexec_failed (cron_task_t *t, int errnum)
{
t->rexec_failed = 1;
t->rexec_errno = errno;
t->rexec_errno = errnum;
cron_task_state_update (t, "Rexec Failure");
}

Expand Down Expand Up @@ -388,7 +388,7 @@ int cron_task_run (cron_task_t *t,
flux_msg_t *msg = NULL;
int rc = -1;

t->match.matchtag = flux_matchtag_alloc (h, FLUX_MATCHTAG_GROUP);
t->match.matchtag = flux_matchtag_alloc (h, 0);
if (t->match.matchtag == FLUX_MATCHTAG_NONE)
return -1;
t->match.topic_glob = "cmb.exec";
Expand Down
4 changes: 4 additions & 0 deletions t/t0005-exec.t
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ test_expect_success 'stdin redirect from /dev/null works' '
test_expect_code 0 run_timeout 1 flux exec -r0-3 cat
'

test_expect_success 'stdin redirect from /dev/null works via -n' '
test_expect_code 0 run_timeout 1 flux exec -n -r0-3 cat
'

test_expect_success 'stdin broadcast -- multiple lines' '
dd if=/dev/urandom bs=1024 count=4 | base64 >expected &&
cat expected | run_timeout 3 flux exec -l -r0-3 cat >output &&
Expand Down

0 comments on commit 72a0550

Please sign in to comment.