ruby-dbus 0.20.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +15 -4
- data/VERSION +1 -1
- data/lib/dbus/message.rb +14 -10
- data/lib/dbus/message_queue.rb +6 -4
- data/lib/dbus.rb +15 -12
- data/spec/raw_message_spec.rb +32 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 922468208faa7a9a13f3c40c0b7ffd22a5a9a6b00de2e30e05e6ae18c84662d5
|
4
|
+
data.tar.gz: 9386581c654bad7f970763c1c67f8984e95654d6f49673a1c3452c2cc59ced0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67e6e4058de8f6e9e0eddc404f53b5219487d711c165dd607ec1138c18f089de560f6467bf6960a28dc0c29b6df2a4a5eee4156e2c2fab68c1dada5ce9383f91
|
7
|
+
data.tar.gz: 364d914924b85f11354fdf8ed3f44f446091422014a92c5c7f0ecc3175cc28236d6a6b0cfec233321657a35554eb24be8692ab83c41a65eb9a75a7eef5dd7a5b
|
data/NEWS.md
CHANGED
@@ -2,6 +2,17 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## Ruby D-Bus 0.21.0 - 2023-04-08
|
6
|
+
|
7
|
+
Features:
|
8
|
+
* Respect env RUBY_DBUS_ENDIANNESS=B (or =l) for outgoing messages.
|
9
|
+
|
10
|
+
Bug fixes:
|
11
|
+
* Reduce socket buffer allocations ([#129][]).
|
12
|
+
* Message#marshall speedup: don't marshall the body twice.
|
13
|
+
|
14
|
+
[#129]: https://github.com/mvidner/ruby-dbus/pull/129
|
15
|
+
|
5
16
|
## Ruby D-Bus 0.20.0 - 2023-03-21
|
6
17
|
|
7
18
|
Features:
|
@@ -82,7 +93,7 @@ API:
|
|
82
93
|
when declaring properties ([#117][]).
|
83
94
|
|
84
95
|
[#115]: https://github.com/mvidner/ruby-dbus/issues/115
|
85
|
-
[#117]: https://github.com/mvidner/ruby-dbus/
|
96
|
+
[#117]: https://github.com/mvidner/ruby-dbus/pull/117
|
86
97
|
|
87
98
|
## Ruby D-Bus 0.18.0.beta7 - 2022-05-29
|
88
99
|
|
@@ -450,7 +461,7 @@ Bug fixes:
|
|
450
461
|
* Handle more ways which tell us that a bus connection has died.
|
451
462
|
|
452
463
|
[#3]: https://github.com/mvidner/ruby-dbus/issue/3
|
453
|
-
[bsc#617350]: https://bugzilla.
|
464
|
+
[bsc#617350]: https://bugzilla.suse.com/show_bug.cgi?id=617350
|
454
465
|
|
455
466
|
## Ruby D-Bus 0.3.0 - 2010-03-28
|
456
467
|
|
@@ -518,8 +529,8 @@ Bug fixes:
|
|
518
529
|
* Fixed an endless sleep in DBus::Main.run ([bsc#537401][]).
|
519
530
|
* Added details to PacketMarshaller exceptions ([bsc#538050][]).
|
520
531
|
|
521
|
-
[bsc#537401]: https://bugzilla.
|
522
|
-
[bsc#538050]: https://bugzilla.
|
532
|
+
[bsc#537401]: https://bugzilla.suse.com/show_bug.cgi?id=537401
|
533
|
+
[bsc#538050]: https://bugzilla.suse.com/show_bug.cgi?id=538050
|
523
534
|
|
524
535
|
## Ruby D-Bus "I'm not dead" 0.2.9 - 2009-08-26
|
525
536
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.21.0
|
data/lib/dbus/message.rb
CHANGED
@@ -10,6 +10,8 @@
|
|
10
10
|
# License, version 2.1 as published by the Free Software Foundation.
|
11
11
|
# See the file "COPYING" for the exact licensing terms.
|
12
12
|
|
13
|
+
require_relative "raw_message"
|
14
|
+
|
13
15
|
# = D-Bus main module
|
14
16
|
#
|
15
17
|
# Module containing all the D-Bus modules and classes.
|
@@ -144,6 +146,10 @@ module DBus
|
|
144
146
|
@params << [type, val]
|
145
147
|
end
|
146
148
|
|
149
|
+
# "l" or "B"
|
150
|
+
ENDIANNESS_CHAR = ENV.fetch("RUBY_DBUS_ENDIANNESS", HOST_END)
|
151
|
+
ENDIANNESS = RawMessage.endianness(ENDIANNESS_CHAR)
|
152
|
+
|
147
153
|
# FIXME: what are these? a message element constant enumeration?
|
148
154
|
# See method below, in a message, you have and array of optional parameters
|
149
155
|
# that come with an index, to determine their meaning. The values are in
|
@@ -165,14 +171,14 @@ module DBus
|
|
165
171
|
raise InvalidDestinationName
|
166
172
|
end
|
167
173
|
|
168
|
-
|
169
|
-
@params.each do |
|
170
|
-
|
174
|
+
params_marshaller = PacketMarshaller.new(endianness: ENDIANNESS)
|
175
|
+
@params.each do |type, value|
|
176
|
+
params_marshaller.append(type, value)
|
171
177
|
end
|
172
|
-
@body_length =
|
178
|
+
@body_length = params_marshaller.packet.bytesize
|
173
179
|
|
174
|
-
marshaller = PacketMarshaller.new
|
175
|
-
marshaller.append(Type::BYTE,
|
180
|
+
marshaller = PacketMarshaller.new(endianness: ENDIANNESS)
|
181
|
+
marshaller.append(Type::BYTE, ENDIANNESS_CHAR.ord)
|
176
182
|
marshaller.append(Type::BYTE, @message_type)
|
177
183
|
marshaller.append(Type::BYTE, @flags)
|
178
184
|
marshaller.append(Type::BYTE, @protocol)
|
@@ -191,10 +197,8 @@ module DBus
|
|
191
197
|
marshaller.append("a(yv)", headers)
|
192
198
|
|
193
199
|
marshaller.align(8)
|
194
|
-
|
195
|
-
|
196
|
-
end
|
197
|
-
marshaller.packet
|
200
|
+
|
201
|
+
marshaller.packet + params_marshaller.packet
|
198
202
|
end
|
199
203
|
|
200
204
|
# Unmarshall a packet contained in the buffer _buf_ and set the
|
data/lib/dbus/message_queue.rb
CHANGED
@@ -18,10 +18,15 @@ module DBus
|
|
18
18
|
# The socket that is used to connect with the bus.
|
19
19
|
attr_reader :socket
|
20
20
|
|
21
|
+
# The buffer size for messages.
|
22
|
+
MSG_BUF_SIZE = 4096
|
23
|
+
|
21
24
|
def initialize(address)
|
22
25
|
DBus.logger.debug "MessageQueue: #{address}"
|
23
26
|
@address = address
|
24
27
|
@buffer = ""
|
28
|
+
# Reduce allocations by using a single buffer for our socket
|
29
|
+
@read_buffer = String.new(capacity: MSG_BUF_SIZE)
|
25
30
|
@is_tcp = false
|
26
31
|
@mutex = Mutex.new
|
27
32
|
connect
|
@@ -157,15 +162,12 @@ module DBus
|
|
157
162
|
ret
|
158
163
|
end
|
159
164
|
|
160
|
-
# The buffer size for messages.
|
161
|
-
MSG_BUF_SIZE = 4096
|
162
|
-
|
163
165
|
# Fill (append) the buffer from data that might be available on the
|
164
166
|
# socket.
|
165
167
|
# @return [void]
|
166
168
|
# @raise EOFError
|
167
169
|
def buffer_from_socket_nonblock
|
168
|
-
@buffer += @socket.read_nonblock(MSG_BUF_SIZE)
|
170
|
+
@buffer += @socket.read_nonblock(MSG_BUF_SIZE, @read_buffer)
|
169
171
|
rescue EOFError
|
170
172
|
raise # the caller expects it
|
171
173
|
rescue Errno::EAGAIN
|
data/lib/dbus.rb
CHANGED
@@ -10,6 +10,21 @@
|
|
10
10
|
# License, version 2.1 as published by the Free Software Foundation.
|
11
11
|
# See the file "COPYING" for the exact licensing terms.
|
12
12
|
|
13
|
+
module DBus
|
14
|
+
# Byte signifying big endianness.
|
15
|
+
BIG_END = "B"
|
16
|
+
# Byte signifying little endianness.
|
17
|
+
LIL_END = "l"
|
18
|
+
|
19
|
+
# Byte signifying the host's endianness.
|
20
|
+
HOST_END = if [0x01020304].pack("L").unpack1("V") == 0x01020304
|
21
|
+
LIL_END
|
22
|
+
else
|
23
|
+
BIG_END
|
24
|
+
end
|
25
|
+
end
|
26
|
+
# ^ That's because dbus/message needs HOST_END early
|
27
|
+
|
13
28
|
require_relative "dbus/api_options"
|
14
29
|
require_relative "dbus/auth"
|
15
30
|
require_relative "dbus/bus"
|
@@ -41,18 +56,6 @@ module DBus
|
|
41
56
|
# Default socket name for the system bus.
|
42
57
|
SYSTEM_BUS_ADDRESS = "unix:path=/var/run/dbus/system_bus_socket"
|
43
58
|
|
44
|
-
# Byte signifying big endianness.
|
45
|
-
BIG_END = "B"
|
46
|
-
# Byte signifying little endianness.
|
47
|
-
LIL_END = "l"
|
48
|
-
|
49
|
-
# Byte signifying the host's endianness.
|
50
|
-
HOST_END = if [0x01020304].pack("L").unpack1("V") == 0x01020304
|
51
|
-
LIL_END
|
52
|
-
else
|
53
|
-
BIG_END
|
54
|
-
end
|
55
|
-
|
56
59
|
# Comparing symbols is faster than strings
|
57
60
|
# @return [:little,:big]
|
58
61
|
HOST_ENDIANNESS = RawMessage.endianness(HOST_END)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env rspec
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "spec_helper"
|
5
|
+
require "dbus"
|
6
|
+
|
7
|
+
# Pedantic full coverage test.
|
8
|
+
# The happy paths are covered via calling classes
|
9
|
+
describe DBus::RawMessage do
|
10
|
+
describe ".endianness" do
|
11
|
+
it "returns :little for 'l'" do
|
12
|
+
expect(described_class.endianness("l")).to eq :little
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns :big for 'B'" do
|
16
|
+
expect(described_class.endianness("B")).to eq :big
|
17
|
+
end
|
18
|
+
|
19
|
+
it "raises for other strings" do
|
20
|
+
expect { described_class.endianness("m") }
|
21
|
+
.to raise_error(DBus::InvalidPacketException, /Incorrect endianness/)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#align" do
|
26
|
+
it "raises for values other than 1 2 4 8" do
|
27
|
+
subject = described_class.new("l")
|
28
|
+
expect { subject.align(3) }.to raise_error(ArgumentError)
|
29
|
+
expect { subject.align(16) }.to raise_error(ArgumentError)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-dbus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruby DBus Team
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rexml
|
@@ -189,6 +189,7 @@ files:
|
|
189
189
|
- spec/property_spec.rb
|
190
190
|
- spec/proxy_object_interface_spec.rb
|
191
191
|
- spec/proxy_object_spec.rb
|
192
|
+
- spec/raw_message_spec.rb
|
192
193
|
- spec/server_robustness_spec.rb
|
193
194
|
- spec/server_spec.rb
|
194
195
|
- spec/service_newapi.rb
|
@@ -210,7 +211,7 @@ homepage: https://github.com/mvidner/ruby-dbus
|
|
210
211
|
licenses:
|
211
212
|
- LGPL-2.1
|
212
213
|
metadata: {}
|
213
|
-
post_install_message:
|
214
|
+
post_install_message:
|
214
215
|
rdoc_options: []
|
215
216
|
require_paths:
|
216
217
|
- lib
|
@@ -226,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
227
|
version: '0'
|
227
228
|
requirements: []
|
228
229
|
rubygems_version: 3.3.0.dev
|
229
|
-
signing_key:
|
230
|
+
signing_key:
|
230
231
|
specification_version: 4
|
231
232
|
summary: Ruby module for interaction with D-Bus
|
232
233
|
test_files: []
|