Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor ruby 1.9 utf-8 fix #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/gearman/util.rb
@@ -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