Skip to content

Commit eab1c4a

Browse files
committed
GH-50302: [GLib][FlightRPC] Add a missing options reference for gaflight_server_listen()
`gaflight_server_listen()` may use options' auth handler later. So we should refer the given options while the server is alive.
1 parent 6570969 commit eab1c4a

8 files changed

Lines changed: 74 additions & 8 deletions

File tree

.github/workflows/ruby.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ jobs:
135135

136136
macos:
137137
name: ARM64 macOS GLib & Ruby
138-
runs-on: macos-latest
138+
runs-on: macos-26
139139
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
140140
timeout-minutes: 60
141141
env:

c_glib/arrow-flight-glib/server.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,7 @@ G_BEGIN_DECLS
11661166
struct GAFlightServerPrivate
11671167
{
11681168
gaflight::Server server;
1169+
GAFlightServerOptions *options;
11691170
};
11701171

11711172
G_END_DECLS
@@ -1196,6 +1197,19 @@ gaflight_server_servable_get_raw(GAFlightServable *servable)
11961197
}
11971198
G_BEGIN_DECLS
11981199

1200+
static void
1201+
gaflight_server_dispose(GObject *object)
1202+
{
1203+
auto priv = GAFLIGHT_SERVER_GET_PRIVATE(object);
1204+
1205+
if (priv->options) {
1206+
g_object_unref(priv->options);
1207+
priv->options = nullptr;
1208+
}
1209+
1210+
G_OBJECT_CLASS(gaflight_server_parent_class)->dispose(object);
1211+
}
1212+
11991213
static void
12001214
gaflight_server_finalize(GObject *object)
12011215
{
@@ -1216,6 +1230,7 @@ static void
12161230
gaflight_server_class_init(GAFlightServerClass *klass)
12171231
{
12181232
auto gobject_class = G_OBJECT_CLASS(klass);
1233+
gobject_class->dispose = gaflight_server_dispose;
12191234
gobject_class->finalize = gaflight_server_finalize;
12201235
}
12211236

@@ -1236,6 +1251,14 @@ gaflight_server_listen(GAFlightServer *server,
12361251
{
12371252
auto flight_server = gaflight_servable_get_raw(GAFLIGHT_SERVABLE(server));
12381253
const auto flight_options = gaflight_server_options_get_raw(options);
1254+
auto priv = GAFLIGHT_SERVER_GET_PRIVATE(server);
1255+
if (priv->options != options) {
1256+
g_object_ref(options);
1257+
if (priv->options) {
1258+
g_object_unref(priv->options);
1259+
}
1260+
priv->options = options;
1261+
}
12391262
return garrow::check(error,
12401263
flight_server->Init(*flight_options),
12411264
"[flight-server][listen]");

c_glib/test/flight/test-criteria.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def setup
2222

2323
def test_expression
2424
expression = "expression"
25-
criteria = ArrowFlight::Criteria.new(expression)
25+
expression_bytes = GLib::Bytes.new(expression)
26+
criteria = ArrowFlight::Criteria.new(expression_bytes)
2627
assert_equal(expression,
2728
criteria.expression.to_s)
2829
end

c_glib/test/flight/test-ticket.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,28 @@ def setup
2222

2323
def test_data
2424
data = "data"
25-
ticket = ArrowFlight::Ticket.new(data)
25+
data_bytes = GLib::Bytes.new(data)
26+
ticket = ArrowFlight::Ticket.new(data_bytes)
2627
assert_equal(data,
2728
ticket.data.to_s)
2829
end
2930

3031
sub_test_case("#==") do
3132
def test_true
32-
ticket1 = ArrowFlight::Ticket.new("data")
33-
ticket2 = ArrowFlight::Ticket.new("data")
33+
data1 = GLib::Bytes.new("data")
34+
data2 = GLib::Bytes.new("data")
35+
ticket1 = ArrowFlight::Ticket.new(data1)
36+
ticket2 = ArrowFlight::Ticket.new(data2)
3437
assert do
3538
ticket1 == ticket2
3639
end
3740
end
3841

3942
def test_false
40-
ticket1 = ArrowFlight::Ticket.new("data1")
41-
ticket2 = ArrowFlight::Ticket.new("data2")
43+
data1 = GLib::Bytes.new("data1")
44+
data2 = GLib::Bytes.new("data2")
45+
ticket1 = ArrowFlight::Ticket.new(data1)
46+
ticket2 = ArrowFlight::Ticket.new(data2)
4247
assert do
4348
not (ticket1 == ticket2)
4449
end

ci/scripts/c_glib_test.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ fi
3636

3737
pushd "${source_dir}"
3838

39-
ruby test/run-test.rb
39+
run_test_args=()
40+
if [ -n "${RUNNER_DEBUG}" ]; then
41+
run_test_args+=(-v)
42+
fi
43+
ruby test/run-test.rb "${run_test_args[@]}"
4044

4145
if [[ "$(uname -s)" == "Linux" ]]; then
4246
# TODO(kszucs): on osx it fails to load 'lgi.corelgilua51' despite that lgi
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
module ArrowFlight
19+
class Criteria
20+
alias_method :initialize_raw, :initialize
21+
def initialize(expression)
22+
initialize_raw(expression)
23+
@expression = expression
24+
end
25+
end
26+
end

ruby/red-arrow-flight/lib/arrow-flight/loader.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def require_libraries
3232
require "arrow-flight/call-options"
3333
require "arrow-flight/client"
3434
require "arrow-flight/client-options"
35+
require "arrow-flight/criteria"
3536
require "arrow-flight/location"
3637
require "arrow-flight/record-batch-reader"
3738
require "arrow-flight/server-call-context"

ruby/red-arrow-flight/lib/arrow-flight/ticket.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,11 @@ def try_convert(value)
2828
end
2929
end
3030
end
31+
32+
alias_method :initialize_raw, :initialize
33+
def initialize(data)
34+
initialize_raw(data)
35+
@data = data
36+
end
3137
end
3238
end

0 commit comments

Comments
 (0)