jcat: get status for all queued messages

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
pull/144/head
Oleksij Rempel 2019-06-25 07:36:36 +02:00
parent 0e542c8dba
commit c4e68aff78
1 changed files with 13 additions and 4 deletions

17
jcat.c
View File

@ -49,6 +49,7 @@ struct jcat_priv {
int outfile;
size_t max_transfer;
unsigned long repeat;
unsigned long round;
int todo_prio;
bool valid_peername;
@ -296,7 +297,8 @@ static int jcat_recv_err(struct jcat_priv *priv)
static int jcat_send_loop(struct jcat_priv *priv, int out_fd, char *buf,
size_t buf_size)
{
ssize_t count, num_sent = 0;
struct jcat_stats *stats = &priv->stats;
ssize_t count;
char *tmp_buf = buf;
unsigned int events = POLLOUT | POLLERR;
bool tx_done = false;
@ -304,6 +306,8 @@ static int jcat_send_loop(struct jcat_priv *priv, int out_fd, char *buf,
count = buf_size;
while (!tx_done) {
ssize_t num_sent = 0;
if (priv->polltimeout) {
struct pollfd fds = {
.fd = priv->sock,
@ -330,7 +334,7 @@ static int jcat_send_loop(struct jcat_priv *priv, int out_fd, char *buf,
continue;
else if (ret)
return ret;
else
else if ((priv->repeat - 1) == stats->tskey)
tx_done = true;
}
@ -353,8 +357,12 @@ static int jcat_send_loop(struct jcat_priv *priv, int out_fd, char *buf,
__func__);
return -EINVAL;
}
if (!count)
events = POLLERR;
if (!count) {
if (priv->repeat == priv->round)
events = POLLERR;
else
tx_done = true;
}
}
return 0;
}
@ -456,6 +464,7 @@ static int jcat_send(struct jcat_priv *priv)
return EXIT_FAILURE;
for (i = 0; i < priv->repeat; i++) {
priv->round++;
ret = jcat_sendfile(priv, priv->sock, priv->infile, NULL, size);
if (ret)
break;