Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
UringMachine is a fiber-based library for creating concurrent apps in Ruby on modern Linux machines. UringMachine provides a rich API for performing I/O using io_uring.
UringMachine is based on my experience marrying Ruby and io_uring:
Some important learnings from those two projects, in no particular order:
So, based on those two projects, I wanted to design a Ruby API for io_uring based on the following principles:
IO
and Socket
classes.When working with io_uring, managing the life cycle of asynchronous operations is quite tricky, especially with regards to cancellation. This is due to the fact each operation lives on both sides of the userspace-kernel divide. This means that when cancelling an operation, we cannot free, or dispose of any resources associated with the operation, until we know for sure that the kernel side is also done with the operation.
As stated above, working with fibers allows us to keep operation metadata and associated data (such as buffers etc) on the stack, which can greatly simplify the managing of the operation's lifetime, as well as significantly reduce heap allocations.
When a cancellation does occur, UringMachine issues a cancellation (using
io_uring_prep_cancel64
), and then waits for the corresponding CQE (with a
-ECANCELED
result).
require 'uringmachine'
machine = UringMachine.new
stdout_fd = STDOUT.fileno
stdin_fd = STDIN.fileno
machine.write(stdout_fd, "Hello, world!\n")
loop do
machine.write(stdout_fd, "Say something: ")
buf = +''
res = machine.read(stdin_fd, buf, 8192)
if res > 0
machine.write(stdout_fd, "You said: #{buf}")
else
break
end
end
Concurrent execution is done by calling #spin
, which creates a fiber:
machine = UringMachine.new
rfd, wfd = machine.pipe
f1 = machine.spin do
machine.write(wfd, 'hello')
machine.write(wfd, 'world')
machine.close(wfd)
end
bgid = machine.setup_buffer_ring(4096, 1024)
f2 = machine.spin do
machine.read_each(rfd, bgid) do |str|
puts str
end
end
FAQs
Unknown package
We found that uringmachine demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.