DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Anatoly Burakov <anatoly.burakov@intel.com>
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [RFC 2/4] eal: enable experimental dlopen()-based secondary process support
Date: Fri, 19 May 2017 10:39:48 -0700	[thread overview]
Message-ID: <20170519103948.4d829353@xeon-e3> (raw)
In-Reply-To: <1495211986-15177-3-git-send-email-anatoly.burakov@intel.com>

On Fri, 19 May 2017 17:39:44 +0100
Anatoly Burakov <anatoly.burakov@intel.com> wrote:

> This new forked secondary dlopen()'s the original secondary process
> binary and runs main() again. In the meantime, the original secondary
> process waits until this new forked secondary dies, and exits.


You don't have to use a lock file. Just using a pipe for process
standard input and detecting close on process exit is often simpler.

> +static
> +const char *get_run_dir(void) {
> +	const char *dir = "/var/run";
> +	const char *home_dir = getenv("HOME");
> +
> +	if (getuid() != 0 && home_dir != NULL)
> +		dir = home_dir;
> +	return dir;
> +}
> +
> +static
> +void get_rand_str(char *str, int sz) {
> +	char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
> +	for (int i = 0; i < sz - 1; i++) {
> +		// this does not give us *true* randomness but it's good enough
> +		int idx = rand() % sizeof(charset);
> +		str[i] = charset[idx];
> +	}
> +	str[sz - 1] = '\0';
> +}
> +
> +/* we need to know its length */
> +static
> +int get_lock_file_path(char *str, int sz) {
> +	char rand_str[16];
> +
> +	get_rand_str(rand_str, 16);
> +
> +	return snprintf(str, sz, LOCKFILE_PATH_FMT, get_run_dir(),
> +	                internal_config.hugefile_prefix, rand_str);
> +}
> +

Why reinvent all the stuff in mkstemp and friends?

Also don't use C++ style comments in DPDK code.

  reply	other threads:[~2017-05-19 17:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-19 16:39 [dpdk-dev] [RFC 0/4] DPDK multiprocess rework Anatoly Burakov
2017-05-19 16:39 ` [dpdk-dev] [RFC 1/4] vfio: refactor sockets into separate files Anatoly Burakov
2017-05-19 16:39 ` [dpdk-dev] [RFC 2/4] eal: enable experimental dlopen()-based secondary process support Anatoly Burakov
2017-05-19 17:39   ` Stephen Hemminger [this message]
2017-05-19 16:39 ` [dpdk-dev] [RFC 3/4] apps: enable new secondary process support in multiprocess apps Anatoly Burakov
2017-05-19 16:39 ` [dpdk-dev] [RFC 4/4] mk: default to compiling shared libraries Anatoly Burakov
2017-07-10 10:18 ` [dpdk-dev] [RFC 0/4] DPDK multiprocess rework Burakov, Anatoly

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=20170519103948.4d829353@xeon-e3 \
    --to=stephen@networkplumber.org \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.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).