[DRE-commits] [ruby-raindrops] 03/04: Add patch to remove scope ids from ipv6 addresses, refresh other patches

Hleb Valoshka tsfgnu-guest at alioth.debian.org
Sat Sep 14 11:07:03 UTC 2013


This is an automated email from the git hooks/post-receive script.

tsfgnu-guest pushed a commit to branch master
in repository ruby-raindrops.

commit 340258e2a24d14132c02f49d0d95b4ec8f386960
Author: Hleb Valoshka <375GNU at Gmail.COM>
Date:   Thu Sep 12 20:53:17 2013 +0300

    Add patch to remove scope ids from ipv6 addresses, refresh other patches
---
 debian/patches/0001-Test-suite-fix-for-IPv6.patch  |    2 +-
 ...Invoke-unix_listener_stats-conditionally.patch} |    6 +-
 ...0003-Remove-Scope-IDs-from-IPv6-addresses.patch |   78 ++++++++++++++++++++
 debian/patches/series                              |    3 +-
 4 files changed, 84 insertions(+), 5 deletions(-)

diff --git a/debian/patches/0001-Test-suite-fix-for-IPv6.patch b/debian/patches/0001-Test-suite-fix-for-IPv6.patch
index e4109f4..b18f4a9 100644
--- a/debian/patches/0001-Test-suite-fix-for-IPv6.patch
+++ b/debian/patches/0001-Test-suite-fix-for-IPv6.patch
@@ -3,7 +3,7 @@ Date: Thu, 15 Mar 2012 21:36:21 +0300
 Subject: Test suite fix for IPv6
 
 ---
- test/test_linux_ipv6.rb |    8 ++++++++
+ test/test_linux_ipv6.rb | 8 ++++++++
  1 file changed, 8 insertions(+)
 
 diff --git a/test/test_linux_ipv6.rb b/test/test_linux_ipv6.rb
diff --git a/debian/patches/0003-Invoke-unix_listener_stats-conditionally.patch b/debian/patches/0002-Invoke-unix_listener_stats-conditionally.patch
similarity index 88%
rename from debian/patches/0003-Invoke-unix_listener_stats-conditionally.patch
rename to debian/patches/0002-Invoke-unix_listener_stats-conditionally.patch
index b1b0511..e3dc63c 100644
--- a/debian/patches/0003-Invoke-unix_listener_stats-conditionally.patch
+++ b/debian/patches/0002-Invoke-unix_listener_stats-conditionally.patch
@@ -6,14 +6,14 @@ unix_listener_stats reads /proc/net/unix on every invokation, that is
 not only expensive, but also breaks the test suite when build process
 isn't allowed to access /proc.
 ---
- lib/raindrops/watcher.rb |    2 +-
+ lib/raindrops/watcher.rb | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/lib/raindrops/watcher.rb b/lib/raindrops/watcher.rb
-index 869fa17..e680a44 100644
+index fb2df5b..0c7c425 100644
 --- a/lib/raindrops/watcher.rb
 +++ b/lib/raindrops/watcher.rb
-@@ -167,7 +167,7 @@ class Raindrops::Watcher
+@@ -171,7 +171,7 @@ class Raindrops::Watcher
      thr = Thread.new do
        begin
          combined = tcp_listener_stats(@tcp_listeners, sock)
diff --git a/debian/patches/0003-Remove-Scope-IDs-from-IPv6-addresses.patch b/debian/patches/0003-Remove-Scope-IDs-from-IPv6-addresses.patch
new file mode 100644
index 0000000..6bfad0f
--- /dev/null
+++ b/debian/patches/0003-Remove-Scope-IDs-from-IPv6-addresses.patch
@@ -0,0 +1,78 @@
+From: Hleb Valoshka <375gnu at gmail.com>
+Date: Thu, 12 Sep 2013 16:31:13 +0300
+Subject: Remove Scope IDs from IPv6 addresses.
+
+	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.
+
+	Tested with MRI and Rubinius.
+---
+ ext/raindrops/linux_inet_diag.c | 41 +++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 39 insertions(+), 2 deletions(-)
+
+diff --git a/ext/raindrops/linux_inet_diag.c b/ext/raindrops/linux_inet_diag.c
+index cd4a876..7b5bae1 100644
+--- a/ext/raindrops/linux_inet_diag.c
++++ b/ext/raindrops/linux_inet_diag.c
+@@ -134,12 +134,49 @@ static int st_free_data(st_data_t key, st_data_t value, st_data_t ignored)
+ 	return ST_DELETE;
+ }
+ 
++/*
++ * call-seq:
++ *      remove_scope_id(ip_address)
++ *
++ * Returns copy of IP address with Scope ID removed,
++ * if address has it (only IPv6 actually may have it).
++ */
++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) {
++		size_t 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 {
++			rb_raise(rb_eArgError,
++				"']' not found in IPv6 addr=%s", ptr);
++                }
++        }
++        return rv;
++}
++
+ static int st_to_hash(st_data_t key, st_data_t value, VALUE hash)
+ {
+ 	struct listen_stats *stats = (struct listen_stats *)value;
+ 
+ 	if (stats->listener_p) {
+-		VALUE k = rb_str_new2((const char *)key);
++		VALUE k = remove_scope_id((const char *)key);
+ 		VALUE v = rb_listen_stats(stats);
+ 
+ 		OBJ_FREEZE(k);
+@@ -153,7 +190,7 @@ static int st_AND_hash(st_data_t key, st_data_t value, VALUE hash)
+ 	struct listen_stats *stats = (struct listen_stats *)value;
+ 
+ 	if (stats->listener_p) {
+-		VALUE k = rb_str_new2((const char *)key);
++		VALUE k = remove_scope_id((const char *)key);
+ 
+ 		if (rb_hash_lookup(hash, k) == Qtrue) {
+ 			VALUE v = rb_listen_stats(stats);
diff --git a/debian/patches/series b/debian/patches/series
index 540c014..986a107 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 0001-Test-suite-fix-for-IPv6.patch
-0003-Invoke-unix_listener_stats-conditionally.patch
+0002-Invoke-unix_listener_stats-conditionally.patch
+0003-Remove-Scope-IDs-from-IPv6-addresses.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-raindrops.git



More information about the Pkg-ruby-extras-commits mailing list