Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/gearman/util.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env ruby

# encoding: UTF-8
require 'socket'
require 'time'

Expand Down Expand Up @@ -69,7 +69,7 @@ def Util.pack_request(type_name, arg='')
type_num = NUMS[type_name.to_sym]
raise InvalidArgsError, "Invalid type name '#{type_name}'" unless type_num
arg = '' if not arg
"\0REQ" + [type_num, arg.size].pack('NN') + arg
"\0REQ" + [type_num, arg.size].pack('NN').force_encoding("UTF-8") + arg
end

##
Expand Down Expand Up @@ -104,9 +104,9 @@ def Util.timed_recv(sock, len, timeout=nil)
or break
data += sock.readpartial(len - data.size)
end
if data.size < len
raise NetworkError, "Read #{data.size} byte(s) instead of #{len}"
end
# if data.bytesize < len
# raise NetworkError, "Read #{data.bytesize} byte(s) instead of #{len}"
# end
data
end

Expand Down Expand Up @@ -135,7 +135,7 @@ def Util.read_response(sock, timeout=nil)
# @param req request packet to send
def Util.send_request(sock, req)
len = sock.write(req)
if len != req.size
if len != req.bytesize
raise NetworkError, "Wrote #{len} instead of #{req.size}"
end
end
Expand Down