raindrops RubyGem user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* Re: [ANN] raindrops 0.13.0 several minor fixes and improvements
  2014-02-18 21:03  7% [ANN] raindrops 0.13.0 several minor fixes and improvements Eric Wong
@ 2014-04-01 20:18  0% ` Eric Wong
  0 siblings, 0 replies; 6+ results
From: Eric Wong @ 2014-04-01 20:18 UTC (permalink / raw)
  To: raindrops

Eric Wong <normalperson@yhbt.net> wrote:
> Hleb Valoshka (1):
>       Remove Scope IDs from IPv6 addresses.

Apparently, this fixes memory bloat/leak for Raindrops::Watcher users on
IPv6-enabled hosts.  I didn't know this before; but upgrading to 0.13.0
fixed a memory bloat/leak issue for a user (reporting via private
email).


^ permalink raw reply	[relevance 0%]

* [ANN] raindrops 0.13.0 several minor fixes and improvements
@ 2014-02-18 21:03  7% Eric Wong
  2014-04-01 20:18  0% ` Eric Wong
  0 siblings, 1 reply; 6+ results
From: Eric Wong @ 2014-02-18 21:03 UTC (permalink / raw)
  To: raindrops

Most notably, this release is necessary for Ruby 2.2 (dev).
Thanks to Koichi Sasada for the bug report!

Eric Wong (5):
      Rakefile: remove raa_update task
      last_data_recv: do not assume Unicorn includes all constants
      raindrops.gemspec: add wrongdoc dev dependency
      linux_inet_diag: fix Ruby 2.2 (dev) build
      license: use LGPLv2.1 or later (was LGPL (2.1|3.0)-only)

Hleb Valoshka (1):
      Remove Scope IDs from IPv6 addresses.

* http://raindrops.bogomips.org/
* raindrops@librelist.org
* git://bogomips.org/raindrops.git
* http://raindrops.bogomips.org/NEWS.atom.xml

-- 
Eric Wong


^ permalink raw reply	[relevance 7%]

* Re: Re: [PATCH] Remove Scope IDs from IPv6 addresses.
  2013-09-10 20:17  6%       ` Eric Wong
@ 2013-09-11 16:12  6%         ` Hleb Valoshka
  0 siblings, 0 replies; 6+ results
From: Hleb Valoshka @ 2013-09-11 16:12 UTC (permalink / raw)
  To: raindrops

On 9/10/13, Eric Wong <normalperson@yhbt.net> wrote:
>> > Perhaps something like this (totally untested, likely off-by-one
>> > errors)
>> Ok, I'll test your code tomorrow.
> Thanks.

Okay, it works, but I was too busy today to test it enough. I hope tomorrow.


^ permalink raw reply	[relevance 6%]

* Re: Re: [PATCH] Remove Scope IDs from IPv6 addresses.
  2013-09-10 19:57  6%     ` Hleb Valoshka
@ 2013-09-10 20:17  6%       ` Eric Wong
  2013-09-11 16:12  6%         ` Hleb Valoshka
  0 siblings, 1 reply; 6+ results
From: Eric Wong @ 2013-09-10 20:17 UTC (permalink / raw)
  To: raindrops

Hleb Valoshka <375gnu@gmail.com> wrote:
> On 9/10/13, Eric Wong <normalperson@yhbt.net> wrote:
> >> +        newaddr = strdup(addr);
> >> +        if (newaddr == NULL)
> >> +                perror("strdup");
> >
> > We'll segfault on strchr below if we perrored above.  If we continue
> > using strdup, I would just use ruby_strdup() (works on both MRI/rbx).
> 
> I haven't use C for a long time, so I thought that strchr checks its args.
> 
> > But I'd rather avoid *strdup entirely.  This is unlikely to
> > remove, right?
> 
> Frankly speaking I dislike functions similar to strdup(), because
> using them you should remember to call free(), sometimes in many
> places (or to use goto). But I'm unfamiliar with internal ruby api, so
> it was the only variant for me.

I try to avoid strdup, too.  I can help you with Ruby C API :)
The advantage of creating Ruby strings right away is it maintains
length, so one can use mem* functions instead of str* functions
(always faster and more explicit, often safer, and never less safe).

> BTW, is anything bad with that variant:
> char *newaddr = alloca(...);
> remove_scope_id(oldaddr, newaddr);

Probably OK in this case, but it would need a comment explaining to stack
checkers the size is bounded and won't overflow.

> > Perhaps something like this (totally untested, likely off-by-one errors)
> 
> Ok, I'll test your code tomorrow.

Thanks.


^ permalink raw reply	[relevance 6%]

* Re: Re: [PATCH] Remove Scope IDs from IPv6 addresses.
  2013-09-10 18:36  6%   ` [PATCH] Remove Scope IDs from IPv6 addresses Eric Wong
@ 2013-09-10 19:57  6%     ` Hleb Valoshka
  2013-09-10 20:17  6%       ` Eric Wong
  0 siblings, 1 reply; 6+ results
From: Hleb Valoshka @ 2013-09-10 19:57 UTC (permalink / raw)
  To: raindrops

On 9/10/13, Eric Wong <normalperson@yhbt.net> wrote:
>> +        newaddr = strdup(addr);
>> +        if (newaddr == NULL)
>> +                perror("strdup");
>
> We'll segfault on strchr below if we perrored above.  If we continue
> using strdup, I would just use ruby_strdup() (works on both MRI/rbx).

I haven't use C for a long time, so I thought that strchr checks its args.

> But I'd rather avoid *strdup entirely.  This is unlikely to
> remove, right?

Frankly speaking I dislike functions similar to strdup(), because
using them you should remember to call free(), sometimes in many
places (or to use goto). But I'm unfamiliar with internal ruby api, so
it was the only variant for me.

BTW, is anything bad with that variant:
char *newaddr = alloca(...);
remove_scope_id(oldaddr, newaddr);

> Perhaps something like this (totally untested, likely off-by-one errors)

Ok, I'll test your code tomorrow.


^ permalink raw reply	[relevance 6%]

* Re: [PATCH] Remove Scope IDs from IPv6 addresses.
       [not found]     ` <20130910183504.GA502@dcvr.yhbt.net>
@ 2013-09-10 18:36  6%   ` Eric Wong
  2013-09-10 19:57  6%     ` Hleb Valoshka
  0 siblings, 1 reply; 6+ results
From: Eric Wong @ 2013-09-10 18:36 UTC (permalink / raw)
  To: raindrops

(Moving to the right list, this thread was originally posted to kgio :x)

Hleb Valoshka <375gnu@gmail.com> wrote:
> 	Scoped ipv6 addresses are defined in rfc4007.
> 	Ruby doesn't support them yet and it's unknown whether it will
> 	(see http://bugs.ruby-lang.org/issues/8464).
> 	So we just remove scope ids.

Thanks.  Comments inline.

> --- a/ext/raindrops/linux_inet_diag.c
> +++ b/ext/raindrops/linux_inet_diag.c
> @@ -134,17 +134,54 @@ static int st_free_data(st_data_t key, st_data_t value, st_data_t ignored)

> +static char* remove_scope_id(const char * addr)
> +{
> +        char *newaddr, *t;
> +
> +        newaddr = strdup(addr);
> +        if (newaddr == NULL)
> +                perror("strdup");

We'll segfault on strchr below if we perrored above.  If we continue
using strdup, I would just use ruby_strdup() (works on both MRI/rbx).

But I'd rather avoid *strdup entirely.  This is unlikely to
remove, right?

> +        t = strchr(newaddr, '%');
> +
> +        if (t != NULL) {
> +                *t = '\0';
> +                t = strchr(t+1, ']');
> +                if (t == NULL)
> +                        fprintf(stderr, "Bad IPv6 address: %s!\n", addr);

Better to use rb_warn/rb_warning.
These are preferable since they allow assigning $stderr to StringIO and
such.  But if we don't use strdup, maybe we could raise instead.

> +                else
> +                        strcat(newaddr, t);
> +        }
> +
> +        return newaddr;
> +}

Perhaps something like this (totally untested, likely off-by-one errors)

static VALUE remove_scope_id(const char *addr)
{
	VALUE rv = rb_str_new2(addr);
	long len = RSTRING_LEN(rv);
	char *ptr = RSTRING_PTR(rv);
	char *pct = memchr(ptr, '%', len);

	/*
	 * remove scoped portion
	 * Ruby equivalent: rv.sub!(/%([^\]]*)\]/, "]")
	 */
	if (pct) {
		long newlen = pct - ptr;
		char *rbracket = memchr(pct, ']', len - newlen);

		if (rbracket) {
			size_t move = len - (rbracket - ptr);

			memmove(pct, rbracket, move);
			newlen += move;

			rb_str_set_len(rv, newlen);
		} else {
			/* perhaps raise here? */
			rb_warn("Bad IPv6 address: %s", addr);
		}
	}
	return rv;
}
-- 
Eric Wong


^ permalink raw reply	[relevance 6%]

Results 1-6 of 6 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
     [not found]     <1378826261-10771-1-git-send-email-375gnu@gmail.com>
     [not found]     ` <20130910183504.GA502@dcvr.yhbt.net>
2013-09-10 18:36  6%   ` [PATCH] Remove Scope IDs from IPv6 addresses Eric Wong
2013-09-10 19:57  6%     ` Hleb Valoshka
2013-09-10 20:17  6%       ` Eric Wong
2013-09-11 16:12  6%         ` Hleb Valoshka
2014-02-18 21:03  7% [ANN] raindrops 0.13.0 several minor fixes and improvements Eric Wong
2014-04-01 20:18  0% ` Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/raindrops.git/

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 read-only IMAP folder(s) and NNTP newsgroup(s).