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-b9f4589650da
unstable
Matt Miller 2006-07-30 18:45:36 +00:00
parent f8ff8c6d7b
commit 144249b34d
1 changed files with 24 additions and 10 deletions

View File

@ -46,20 +46,34 @@ class EncodedPayload
self.encoder = nil
self.nop = nil
# First, validate
pinst.validate()
# Increase thread priority as necessary. This is done
# 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
generate_raw()
if (priority == 0)
Thread.current.priority = 1
end
# Encode the payload
encode()
begin
# First, validate
pinst.validate()
# Build the NOP sled
generate_sled()
# Generate the raw version of the payload first
generate_raw()
# Finally, set the complete payload definition
self.encoded = (self.nop_sled || '') + self.encoded
# Encode the payload
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 encoded