Control: forwarded -1 https://github.com/petergoldstein/dalli/issues/1034

Hi,

I tracked this down to this MWE:

require 'dalli'
dc = Dalli::Client.new('localhost:11211', { namespace: "app_v1" })
dc.flush_all

which fails on armel with:

/usr/share/rubygems-integration/all/gems/dalli-3.2.8/lib/dalli/socket.rb:133:in 
`setsockopt': Invalid argument - setsockopt(2) (Errno::EINVAL)
        from 
/usr/share/rubygems-integration/all/gems/dalli-3.2.8/lib/dalli/socket.rb:133:in 
`init_socket_options'
        from 
/usr/share/rubygems-integration/all/gems/dalli-3.2.8/lib/dalli/socket.rb:94:in 
`block in open'
        from 
/usr/share/rubygems-integration/all/gems/dalli-3.2.8/lib/dalli/socket.rb:110:in 
`create_socket_with_timeout'
        from 
/usr/share/rubygems-integration/all/gems/dalli-3.2.8/lib/dalli/socket.rb:92:in 
`open'
[...]

or using strace:

[pid 59410] setsockopt(5, SOL_TCP, TCP_NODELAY, [1], 4) = 0
[pid 59410] setsockopt(5, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
[pid 59410] setsockopt(5, SOL_SOCKET, SO_RCVTIMEO_NEW, "\1\0\0\0\0\0\0\0", 8) = 
-1 EINVAL (Invalid argument)

The relevant upstream change is:
https://github.com/petergoldstein/dalli/pull/1025/commits/1a7af32f0ccd4a20c4e2d0b4f2adc1ca29046e48

And specifically this code:

 seconds, fractional = options[:socket_timeout].divmod(1)
 timeval = [seconds, fractional * 1_000_000].pack('l_2')

 sock.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_RCVTIMEO, timeval)
 sock.setsockopt(::Socket::SOL_SOCKET, ::Socket::SO_SNDTIMEO, timeval)

The problem here is that the packing of seconds, microseconds into a
struct timeval is architecture-dependent, and cannot be assumed to be
solved by pack('l_2').

I opened https://github.com/petergoldstein/dalli/issues/1034

Lucas

Reply via email to