Avoid call to rb_string_value_cstr() which doesn't handle binary strings from Ruby properly

Fixes #32
This commit is contained in:
R. Tyler Croy 2014-09-10 19:59:21 -07:00
parent 838904a035
commit 7af7e3ec5b
2 changed files with 4 additions and 2 deletions

View File

@ -573,11 +573,13 @@ static VALUE producer_push_single(VALUE self, VALUE message, VALUE result) {
TRACER("setting result: %p\n", result);
}
TRACER("rd_kafka_produce() message of %i bytes\n", RSTRING_LEN(message));
/* Send/Produce message. */
if (-1 == rd_kafka_produce(producerConfig->rkt,
producerConfig->partition,
RD_KAFKA_MSG_F_COPY,
rb_string_value_cstr(&message),
RSTRING_PTR(message),
RSTRING_LEN(message),
NULL,
0,

View File

@ -68,7 +68,7 @@ describe Hermann::Lib::Producer do
end
context 'with binary data' do
let(:message) { "\n+AuOzetQrTrdwSY14ig7I_1oUwjp3DvTx3YWhSTGD4Fo\022\0312014-09-10T00:18:47-07:00\032,\n\006scream\022\016missing_device\032\022app0\"\t\n\astarted*(\b\000\022$009f0305-b50a-455d-b137-e52b45f674aa*(\b\001\022$53c0d817-d94b-4b7a-9a58-95fe8cec4333" }
let(:message) { "\n+AuOzetQrTrdwSY14ig7I_1oUwjp3DvTx3YWhSTGD4Fo\022\0312014-09-10T00:18:47-07:00\032,\n\006scream\022\016missing_device\032\022flexd-today-0-app0\"\t\n\astarted*(\b\000\022$009f0305-b50a-455d-b137-e52b45f674aa*(\b\001\022$53c0d817-d94b-4b7a-9a58-95fe8cec4333" }
it 'should return' do
expect(push).not_to be_nil