netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Chris Mi <chrism@mellanox.com>
Cc: netdev@vger.kernel.org, gerlitz.or@gmail.com,
	stephen@networkplumber.org, dsahern@gmail.com
Subject: Re: [patch iproute2 v4 2/3] tc: Add -bs option to batch mode
Date: Tue, 2 Jan 2018 18:04:25 -0200	[thread overview]
Message-ID: <20180102200425.GA725@localhost.localdomain> (raw)
In-Reply-To: <20180102142804.27145-3-chrism@mellanox.com>

On Tue, Jan 02, 2018 at 11:28:03PM +0900, Chris Mi wrote:
> @@ -240,23 +244,49 @@ static int batch(const char *name)
>  	}
>  
>  	cmdlineno = 0;
> -	while (getcmdline(&line, &len, stdin) != -1) {
> +	if (getcmdline(&line, &len, stdin) == -1)
> +		goto Exit;
> +	do {
>  		char *largv[100];
>  		int largc;
>  
> +		if (getcmdline(&line2, &len, stdin) == -1)
> +			lastline = true;
> +
>  		largc = makeargs(line, largv, 100);
>  		if (largc == 0)
>  			continue;	/* blank line */

If it reads a new line, it won't process anything else after it
because line won't get updated.

  Marcelo

>  
> -		if (do_cmd(largc, largv)) {
> -			fprintf(stderr, "Command failed %s:%d\n", name, cmdlineno);
> +		line = line2;
> +		line2 = NULL;
> +		len = 0;
> +
> +		/*
> +		 * In batch mode, if we haven't accumulated enough commands
> +		 * and this is not the last command, don't send the message
> +		 * immediately.
> +		 */
> +		if (batch_size > 1 && msg_iov_index + 1 != batch_size
> +		    && !lastline)
> +			send = false;
> +		else
> +			send = true;
> +
> +		ret = do_cmd(largc, largv, batch_size, msg_iov_index++, send);
> +		if (ret < 0) {
> +			fprintf(stderr, "Command failed %s:%d\n", name,
> +				cmdlineno);
>  			ret = 1;
>  			if (!force)
>  				break;
>  		}
> -	}
> -	if (line)
> -		free(line);
> +		msg_iov_index %= batch_size;
> +	} while (!lastline);
> +
> +	free_filter_reqs();
> +	free_action_reqs();
> +Exit:
> +	free(line);
>  
>  	rtnl_close(&rth);
>  	return ret;

  reply	other threads:[~2018-01-02 20:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-02 14:28 [patch iproute2 v4 0/3] tc: Add -bs option to batch mode Chris Mi
2018-01-02 14:28 ` [patch iproute2 v4 1/3] lib/libnetlink: Add a function rtnl_talk_msg Chris Mi
2018-01-02 14:28 ` [patch iproute2 v4 2/3] tc: Add -bs option to batch mode Chris Mi
2018-01-02 20:04   ` Marcelo Ricardo Leitner [this message]
2018-01-03  2:44     ` Chris Mi
2018-01-02 14:28 ` [patch iproute2 v4 3/3] man: Add -bs option to tc manpage Chris Mi
2018-01-02 20:07   ` Marcelo Ricardo Leitner
2018-01-03  2:48     ` Chris Mi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180102200425.GA725@localhost.localdomain \
    --to=marcelo.leitner@gmail.com \
    --cc=chrism@mellanox.com \
    --cc=dsahern@gmail.com \
    --cc=gerlitz.or@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).