Ignore:
Timestamp:
Apr 16, 2008, 12:11:35 AM (15 years ago)
Author:
Sam Hocevar
Message:
  • Better error reporting and argument passing from/to the bytecode.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • research/2008-displacement/main-cpushare

    r2286 r2287  
    1818    sys.exit(-1)
    1919mode = sys.argv[2][1]
     20done = 0
    2021source = sys.argv[3:]
    2122result = [False] * len(source)
     
    3536        global todo, source
    3637        if todo >= len(source):
    37             return # We're finished... FIXME: a process is stuck
     38            return # We're finished... FIXME: is the transaction kept stuck?
    3839        self.index = todo
    3940        todo += 1
    4041        gd.gdMaxColors = 256 * 256 * 256
    4142        im = gd.image(source[self.index])
    42         # Send mode
    43         self.protocol.sendString(PROTO_SECCOMP_FORWARD + mode)
     43        # Send argument count
     44        self.protocol.sendString(PROTO_SECCOMP_FORWARD + chr(3))
     45        # Send arguments
     46        msg = chr(3)
     47        msg += "bytecode\0"
     48        msg += "-1\0"
     49        msg += source[self.index] + "\0"
     50        self.protocol.sendString(PROTO_SECCOMP_FORWARD + msg)
    4451        # Send image size
    4552        (self.w, self.h) = (w, h) = im.size()
     
    6572            if ord(self.answer[-1]) != 0:
    6673                return
    67             global result
     74            global done, result
    6875            result[self.index] = self.answer[:-1]
    6976            print self.answer[:-1],
    7077            self.protocol.sendString(PROTO_SECCOMP_SUCCESS)
    71             # the PROTO_SECCOMP_SUCCESS probably won't have a chance
    72             # to go out but it doesn't matter because we'll disconnect
    73             # not just this but all other seccomp state machines too
     78            done += 1
     79            if done < len(source):
     80                return
    7481            from twisted.internet import reactor
    7582            reactor.stop()
Note: See TracChangeset for help on using the changeset viewer.