* [PATCH 0/5] miscellaneous updates
@ 2017-03-03 20:53 Eric Wong
2017-03-03 20:53 ` [PATCH 1/5] gemspec: use SPDX compatible terms for the license(s) Eric Wong
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Eric Wong @ 2017-03-03 20:53 UTC (permalink / raw)
To: kcar-public
Mainly modernizing and stealing some features from unicorn,
and perhaps prototyping some new ones.
Will still need to shrink the struct a bit while ensuring
we don't exceed limits and such.
Eric Wong (5):
gemspec: use SPDX compatible terms for the license(s)
archive/slrnpull.conf: add a note explaining the purpose
drop rb_str_set_len compatibility replacement
remove rb_str_modify workaround
TypedData C-API conversion
archive/slrnpull.conf | 3 +++
ext/kcar/ext_help.h | 24 ------------------------
ext/kcar/extconf.rb | 2 --
ext/kcar/kcar.rl | 36 ++++++++++++++++++++++++------------
kcar.gemspec | 8 +++++++-
test/test_parser.rb | 8 ++++++++
6 files changed, 42 insertions(+), 39 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/5] gemspec: use SPDX compatible terms for the license(s)
2017-03-03 20:53 [PATCH 0/5] miscellaneous updates Eric Wong
@ 2017-03-03 20:53 ` Eric Wong
2017-03-03 20:53 ` [PATCH 2/5] archive/slrnpull.conf: add a note explaining the purpose Eric Wong
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Eric Wong @ 2017-03-03 20:53 UTC (permalink / raw)
To: kcar-public
This should make things less confusing for automated license
checkers. Disclaimer: I don't like or even understand the
original Ruby license, but only maintain it out of respect for
the original Mongrel license.
---
kcar.gemspec | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/kcar.gemspec b/kcar.gemspec
index 6283992..3d8d39d 100644
--- a/kcar.gemspec
+++ b/kcar.gemspec
@@ -19,5 +19,11 @@ Gem::Specification.new do |s|
s.add_development_dependency('olddoc', '~> 1.0')
s.add_development_dependency('test-unit', '~> 3.0')
- s.licenses = %w(GPLv2+ Ruby)
+ # Note: To avoid ambiguity, we intentionally avoid the SPDX-compatible
+ # 'Ruby' for the Ruby 1.8 license. This is because Ruby 1.9.3 switched
+ # to BSD-2-Clause, but we inherited our license from Mongrel when
+ # Ruby was at 1.8. We cannot automatically switch licenses when Ruby
+ # changes; so we maintain the Ruby 1.8 license (not 1.9.3+) along
+ # with GPL-2.0+
+ s.licenses = %w(GPL-2.0+ Nonstandard)
end
--
EW
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/5] archive/slrnpull.conf: add a note explaining the purpose
2017-03-03 20:53 [PATCH 0/5] miscellaneous updates Eric Wong
2017-03-03 20:53 ` [PATCH 1/5] gemspec: use SPDX compatible terms for the license(s) Eric Wong
@ 2017-03-03 20:53 ` Eric Wong
2017-03-03 20:53 ` [PATCH 3/5] drop rb_str_set_len compatibility replacement Eric Wong
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Eric Wong @ 2017-03-03 20:53 UTC (permalink / raw)
To: kcar-public
In case somebody stumbles upon it...
---
archive/slrnpull.conf | 3 +++
1 file changed, 3 insertions(+)
diff --git a/archive/slrnpull.conf b/archive/slrnpull.conf
index c48d263..f06bd7f 100644
--- a/archive/slrnpull.conf
+++ b/archive/slrnpull.conf
@@ -1,3 +1,6 @@
+# This config was used to create the import used to migrate
+# mailing list archives from gmane to https://bogomips.org/kcar-public/
+
# group_name max expire headers_only
gmane.comp.lang.ruby.kcar.general 1000000000 1000000000 0
--
EW
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/5] drop rb_str_set_len compatibility replacement
2017-03-03 20:53 [PATCH 0/5] miscellaneous updates Eric Wong
2017-03-03 20:53 ` [PATCH 1/5] gemspec: use SPDX compatible terms for the license(s) Eric Wong
2017-03-03 20:53 ` [PATCH 2/5] archive/slrnpull.conf: add a note explaining the purpose Eric Wong
@ 2017-03-03 20:53 ` Eric Wong
2017-03-03 20:53 ` [PATCH 4/5] remove rb_str_modify workaround Eric Wong
2017-03-03 20:53 ` [PATCH 5/5] TypedData C-API conversion Eric Wong
4 siblings, 0 replies; 6+ messages in thread
From: Eric Wong @ 2017-03-03 20:53 UTC (permalink / raw)
To: kcar-public
While it is innocuous after compiling, it can be a confusing
source of errors for users with broken installations of Ruby
itself:
https://bogomips.org/unicorn-public/5ace6a20-e094-293d-93df-b557480e12d5@anyces.com/
https://bogomips.org/unicorn-public/02994a55-9c07-a3c5-f06b-a4c15551a67e@anyces.com/
rb_str_set_len has been provided since Ruby 1.8.7+, and we'll
be requiring Ruby 1.9.3+ in the future (and even Ruby 2.2 is EOL
nowadays)
---
ext/kcar/ext_help.h | 20 --------------------
ext/kcar/extconf.rb | 1 -
2 files changed, 21 deletions(-)
diff --git a/ext/kcar/ext_help.h b/ext/kcar/ext_help.h
index ec081e2..d227737 100644
--- a/ext/kcar/ext_help.h
+++ b/ext/kcar/ext_help.h
@@ -1,26 +1,6 @@
#ifndef ext_help_h
#define ext_help_h
-#ifndef RSTRING_PTR
-#define RSTRING_PTR(s) (RSTRING(s)->ptr)
-#endif /* !defined(RSTRING_PTR) */
-#ifndef RSTRING_LEN
-#define RSTRING_LEN(s) (RSTRING(s)->len)
-#endif /* !defined(RSTRING_LEN) */
-
-#ifndef HAVE_RB_STR_SET_LEN
-# ifdef RUBINIUS
-# error we should never get here with current Rubinius (1.x)
-# endif
-/* this is taken from Ruby 1.8.7, 1.8.6 may not have it */
-static void rb_18_str_set_len(VALUE str, long len)
-{
- RSTRING(str)->len = len;
- RSTRING(str)->ptr[len] = '\0';
-}
-# define rb_str_set_len(str,len) rb_18_str_set_len(str,len)
-#endif /* !defined(HAVE_RB_STR_SET_LEN) */
-
/* not all Ruby implementations support frozen objects (Rubinius does not) */
#if defined(OBJ_FROZEN)
# define assert_frozen(f) assert(OBJ_FROZEN(f) && "unfrozen object")
diff --git a/ext/kcar/extconf.rb b/ext/kcar/extconf.rb
index 4f19c4a..3585125 100644
--- a/ext/kcar/extconf.rb
+++ b/ext/kcar/extconf.rb
@@ -5,7 +5,6 @@ dir_config("kcar")
have_macro("SIZEOF_OFF_T", "ruby.h") or check_sizeof("off_t", "sys/types.h")
have_macro("SIZEOF_LONG", "ruby.h") or check_sizeof("long", "sys/types.h")
-have_func("rb_str_set_len", "ruby.h")
have_func("rb_str_modify", "ruby.h")
# -fPIC is needed for Rubinius, MRI already uses it regardless
--
EW
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/5] remove rb_str_modify workaround
2017-03-03 20:53 [PATCH 0/5] miscellaneous updates Eric Wong
` (2 preceding siblings ...)
2017-03-03 20:53 ` [PATCH 3/5] drop rb_str_set_len compatibility replacement Eric Wong
@ 2017-03-03 20:53 ` Eric Wong
2017-03-03 20:53 ` [PATCH 5/5] TypedData C-API conversion Eric Wong
4 siblings, 0 replies; 6+ messages in thread
From: Eric Wong @ 2017-03-03 20:53 UTC (permalink / raw)
To: kcar-public
Every supported Ruby implementation has a rb_str_modify
wrapper.
---
ext/kcar/ext_help.h | 4 ----
ext/kcar/extconf.rb | 1 -
2 files changed, 5 deletions(-)
diff --git a/ext/kcar/ext_help.h b/ext/kcar/ext_help.h
index d227737..a0e21e2 100644
--- a/ext/kcar/ext_help.h
+++ b/ext/kcar/ext_help.h
@@ -16,10 +16,6 @@
# endif
#endif /* ! defined(OFFT2NUM) */
-#ifndef HAVE_RB_STR_MODIFY
-# define rb_str_modify(x) do {} while (0)
-#endif /* ! defined(HAVE_RB_STR_MODIFY) */
-
static inline int str_cstr_eq(VALUE val, const char *ptr, long len)
{
return (RSTRING_LEN(val) == len && !memcmp(ptr, RSTRING_PTR(val), len));
diff --git a/ext/kcar/extconf.rb b/ext/kcar/extconf.rb
index 3585125..7ab5b4b 100644
--- a/ext/kcar/extconf.rb
+++ b/ext/kcar/extconf.rb
@@ -5,7 +5,6 @@ dir_config("kcar")
have_macro("SIZEOF_OFF_T", "ruby.h") or check_sizeof("off_t", "sys/types.h")
have_macro("SIZEOF_LONG", "ruby.h") or check_sizeof("long", "sys/types.h")
-have_func("rb_str_modify", "ruby.h")
# -fPIC is needed for Rubinius, MRI already uses it regardless
with_cflags($CFLAGS + " -fPIC ") do
--
EW
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 5/5] TypedData C-API conversion
2017-03-03 20:53 [PATCH 0/5] miscellaneous updates Eric Wong
` (3 preceding siblings ...)
2017-03-03 20:53 ` [PATCH 4/5] remove rb_str_modify workaround Eric Wong
@ 2017-03-03 20:53 ` Eric Wong
4 siblings, 0 replies; 6+ messages in thread
From: Eric Wong @ 2017-03-03 20:53 UTC (permalink / raw)
To: kcar-public
This provides some extra type safety if combined with other
C extensions, as well as allowing us to account for memory usage of
the HTTP parser in ObjectSpace.
This requires Ruby 1.9.3+ and has remained a stable API since
then. This will become officially supported when Ruby 2.3.0 is
released later this month.
This API has only been documented in doc/extension.rdoc (formerly
README.EXT) in the Ruby source tree since April 2015, r50318
---
ext/kcar/kcar.rl | 36 ++++++++++++++++++++++++------------
test/test_parser.rb | 8 ++++++++
2 files changed, 32 insertions(+), 12 deletions(-)
diff --git a/ext/kcar/kcar.rl b/ext/kcar/kcar.rl
index 1130b75..4c66fb5 100644
--- a/ext/kcar/kcar.rl
+++ b/ext/kcar/kcar.rl
@@ -409,29 +409,41 @@ post_exec: /* "_out:" also goes here */
assert(hp->offset <= len && "offset longer than length");
}
-static struct http_parser *data_get(VALUE self)
+static void kcar_mark(void *ptr)
{
- struct http_parser *hp;
+ struct http_parser *hp = ptr;
- Data_Get_Struct(self, struct http_parser, hp);
- assert(hp && "failed to extract http_parser struct");
- return hp;
+ rb_gc_mark(hp->cont);
+ rb_gc_mark(hp->status);
}
-static void mark(void *ptr)
+static size_t kcar_memsize(const void *ptr)
{
- struct http_parser *hp = ptr;
+ return sizeof(struct http_parser);
+}
- rb_gc_mark(hp->cont);
- rb_gc_mark(hp->status);
+static const rb_data_type_t kcar_type = {
+ "kcar_parser",
+ { kcar_mark, RUBY_TYPED_DEFAULT_FREE, kcar_memsize, /* reserved */ },
+ /* parent, data, [ flags ] */
+};
+
+static VALUE kcar_alloc(VALUE klass)
+{
+ struct http_parser *hp;
+ return TypedData_Make_Struct(klass, struct http_parser, &kcar_type, hp);
}
-static VALUE alloc(VALUE klass)
+static struct http_parser *data_get(VALUE self)
{
struct http_parser *hp;
- return Data_Make_Struct(klass, struct http_parser, mark, -1, hp);
+
+ TypedData_Get_Struct(self, struct http_parser, &kcar_type, hp);
+ assert(hp && "failed to extract http_parser struct");
+ return hp;
}
+
/**
* call-seq:
* Kcar::Parser.new => parser
@@ -678,7 +690,7 @@ void Init_kcar_ext(void)
eParserError = rb_define_class_under(mKcar, "ParserError", rb_eIOError);
- rb_define_alloc_func(cParser, alloc);
+ rb_define_alloc_func(cParser, kcar_alloc);
rb_define_method(cParser, "initialize", initialize, 0);
rb_define_method(cParser, "reset", initialize, 0);
rb_define_method(cParser, "headers", headers, 2);
diff --git a/test/test_parser.rb b/test/test_parser.rb
index dab2e77..c8eaa4d 100644
--- a/test/test_parser.rb
+++ b/test/test_parser.rb
@@ -289,4 +289,12 @@ class TestParser < Test::Unit::TestCase
assert @hp.headers(env = {}, resp)
assert_equal '', env['Host']
end
+
+ def test_memsize
+ require 'objspace'
+ n = ObjectSpace.memsize_of(@hp)
+ assert_kind_of Integer, n
+ rescue LoadError
+ warn 'ObjectSpace not available'
+ end
end
--
EW
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-03-03 20:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-03 20:53 [PATCH 0/5] miscellaneous updates Eric Wong
2017-03-03 20:53 ` [PATCH 1/5] gemspec: use SPDX compatible terms for the license(s) Eric Wong
2017-03-03 20:53 ` [PATCH 2/5] archive/slrnpull.conf: add a note explaining the purpose Eric Wong
2017-03-03 20:53 ` [PATCH 3/5] drop rb_str_set_len compatibility replacement Eric Wong
2017-03-03 20:53 ` [PATCH 4/5] remove rb_str_modify workaround Eric Wong
2017-03-03 20:53 ` [PATCH 5/5] TypedData C-API conversion Eric Wong
Code repositories for project(s) associated with this public inbox
https://yhbt.net/kcar.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).