[DRE-commits] [ruby-patron] 04/05: Ruby 2.2 added patches from upstrean (Closes: #791782)

Jonas Genannt genannt at moszumanska.debian.org
Tue Aug 25 19:13:10 UTC 2015


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

genannt pushed a commit to branch master
in repository ruby-patron.

commit 9dffe0b1a9a0c0c6370bbd32b6c914a07af0ddd3
Author: Jonas Genannt <jonas at brachium-system.net>
Date:   Tue Aug 25 21:13:40 2015 +0200

    Ruby 2.2 added patches from upstrean (Closes: #791782)
---
 debian/patches/fix_incorrect_element.patch | 41 +++++++++++++++++++++
 debian/patches/ruby22.patch                | 57 ++++++++++++++++++++++++++++++
 debian/patches/series                      |  3 ++
 3 files changed, 101 insertions(+)

diff --git a/debian/patches/fix_incorrect_element.patch b/debian/patches/fix_incorrect_element.patch
new file mode 100644
index 0000000..8e6c90e
--- /dev/null
+++ b/debian/patches/fix_incorrect_element.patch
@@ -0,0 +1,41 @@
+From 62135866a7533941c927d06cf47a2813f2f68256 Mon Sep 17 00:00:00 2001
+From: Vladimir Kochnev <hashtable at yandex.ru>
+Date: Mon, 18 May 2015 17:33:24 +0300
+Subject: [PATCH] Fix incorrect list element comparator.
+Bug: https://github.com/marshall-lee/patron/commit/62135866a7533941c927d06cf47a2813f2f68256
+
+List elements was being comparing incorrectly.
+C operator `==` returns 1 on equal elements but SGLIB wants a zero.
+As a consequence `ruby_xfree` was being calling on memory regions that are in
+use. It caused random segfaults when using Patron.
+
+Also this patch optimizes list element deletion: there is a convenient
+SGLIB macro `SGLIB_LIST_DELETE_IF_MEMBER` so there's no need to go
+through list twice.
+---
+ ext/patron/session_ext.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- a/ext/patron/session_ext.c
++++ b/ext/patron/session_ext.c
+@@ -109,7 +109,7 @@
+   struct curl_state_list  *next;
+ };
+ 
+-#define CS_LIST_COMPARATOR(p, _state_) (p->state == _state_)
++#define CS_LIST_COMPARATOR(p, _state_) (p->state - _state_)
+ 
+ static struct curl_state_list *cs_list = NULL;
+ 
+@@ -128,9 +128,9 @@
+   struct curl_state_list *item = NULL;
+ 
+   assert(state != NULL);
+-  SGLIB_LIST_FIND_MEMBER(struct curl_state_list, cs_list, state, CS_LIST_COMPARATOR, next, item);
++
++  SGLIB_LIST_DELETE_IF_MEMBER(struct curl_state_list, cs_list, state, CS_LIST_COMPARATOR, next, item);
+   if (item) {
+-    SGLIB_LIST_DELETE(struct curl_state_list, cs_list, item, next);
+     ruby_xfree(item);
+   }
+ }
diff --git a/debian/patches/ruby22.patch b/debian/patches/ruby22.patch
new file mode 100644
index 0000000..0b9d0be
--- /dev/null
+++ b/debian/patches/ruby22.patch
@@ -0,0 +1,57 @@
+From cb5b3f7b2529a30a987845611da5e84e1897172d Mon Sep 17 00:00:00 2001
+From: Vladimir Kochnev <hashtable at yandex.ru>
+Date: Fri, 15 May 2015 14:40:16 +0300
+Subject: [PATCH] use rb_thread_call_without_gvl if possible
+
+rb_thread_blocking_region is deprecated since 2.0 and completely removed
+in 2.2. rb_thread_call_without_gvl should be used instead on all rubies
+that already have it.
+---
+ ext/patron/extconf.rb    |  4 +++-
+ ext/patron/session_ext.c | 12 +++++++++++-
+ 2 files changed, 14 insertions(+), 2 deletions(-)
+
+--- a/ext/patron/extconf.rb
++++ b/ext/patron/extconf.rb
+@@ -44,6 +44,8 @@
+ end
+ 
+ $defs.push("-DUSE_TBR")
+-$defs.push("-DHAVE_TBR") if have_func('rb_thread_blocking_region')
++$defs.push("-DHAVE_THREAD_H") if have_header('ruby/thread.h')
++$defs.push("-DHAVE_TBR") if have_func('rb_thread_blocking_region', 'ruby.h')
++$defs.push("-DHAVE_TCWOGVL") if have_header('ruby/thread.h') && have_func('rb_thread_call_without_gvl', 'ruby/thread.h')
+ 
+ create_makefile 'patron/session_ext'
+--- a/ext/patron/session_ext.c
++++ b/ext/patron/session_ext.c
+@@ -23,6 +23,9 @@
+  *
+ \* -------------------------------------------------------------------------- */
+ #include <ruby.h>
++#if defined(USE_TBR) && defined(HAVE_THREAD_H)
++#include <ruby/thread.h>
++#endif
+ #include <curl/curl.h>
+ #include "membuffer.h"
+ #include "sglib.h"  /* Simple Generic Library -> http://sglib.sourceforge.net */
+@@ -593,11 +596,18 @@
+     curl_easy_setopt(curl, CURLOPT_WRITEDATA, body_buffer);
+   }
+ 
+-#if defined(HAVE_TBR) && defined(USE_TBR)
++#if (defined(HAVE_TBR) || defined(HAVE_TCWOGVL)) && defined(USE_TBR)
++#if defined(HAVE_TCWOGVL)
++  ret = (CURLcode) rb_thread_call_without_gvl(
++          (void *(*)(void *)) curl_easy_perform, curl,
++          RUBY_UBF_IO, 0
++        );
++#else
+   ret = (CURLcode) rb_thread_blocking_region(
+           (rb_blocking_function_t*) curl_easy_perform, curl,
+           RUBY_UBF_IO, 0
+         );
++#endif
+ #else
+   ret = curl_easy_perform(curl);
+ #endif
diff --git a/debian/patches/series b/debian/patches/series
index 644fc8d..c58f52f 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,4 @@
 tests-disable-load-path
+disabled_sslv3.patch
+fix_incorrect_element.patch
+ruby22.patch

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



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