bump thread priority in encoded payload generation to fix thread starvation issues
git-svn-id: file:///home/svn/framework3/trunk@3777 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
f8ff8c6d7b
commit
144249b34d
|
@ -46,20 +46,34 @@ class EncodedPayload
|
||||||
self.encoder = nil
|
self.encoder = nil
|
||||||
self.nop = nil
|
self.nop = nil
|
||||||
|
|
||||||
# First, validate
|
# Increase thread priority as necessary. This is done
|
||||||
pinst.validate()
|
# to ensure that the encoding and sled generation get
|
||||||
|
# enough time slices from the ruby thread scheduler.
|
||||||
|
priority = Thread.current.priority
|
||||||
|
|
||||||
# Generate the raw version of the payload first
|
if (priority == 0)
|
||||||
generate_raw()
|
Thread.current.priority = 1
|
||||||
|
end
|
||||||
|
|
||||||
# Encode the payload
|
begin
|
||||||
encode()
|
# First, validate
|
||||||
|
pinst.validate()
|
||||||
|
|
||||||
# Build the NOP sled
|
# Generate the raw version of the payload first
|
||||||
generate_sled()
|
generate_raw()
|
||||||
|
|
||||||
# Finally, set the complete payload definition
|
# Encode the payload
|
||||||
self.encoded = (self.nop_sled || '') + self.encoded
|
encode()
|
||||||
|
|
||||||
|
# Build the NOP sled
|
||||||
|
generate_sled()
|
||||||
|
|
||||||
|
# Finally, set the complete payload definition
|
||||||
|
self.encoded = (self.nop_sled || '') + self.encoded
|
||||||
|
ensure
|
||||||
|
# Restore the thread priority
|
||||||
|
Thread.current.priority = priority
|
||||||
|
end
|
||||||
|
|
||||||
# Return the complete payload
|
# Return the complete payload
|
||||||
return encoded
|
return encoded
|
||||||
|
|
Loading…
Reference in New Issue