Skip to content

Commit

Permalink
Added workaround for reading bytes-in-order
Browse files Browse the repository at this point in the history
  • Loading branch information
calcinai committed Jun 6, 2016
1 parent 4ba090b commit 5bec547
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/MMap/StreamWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ private function subprocess_write($command, $data = ''){
* @return string
*/
private function subprocess_read($length){
return fread($this->pipes[1], $length);
$data = fread($this->pipes[1], $length);
return $data;
}


Expand Down
10 changes: 8 additions & 2 deletions subprocess/mmap-proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@
mem.seek(address)
elif(command == 'r'):
length = struct.unpack('<H', sys.stdin.read(2))[0];
sys.stdout.write(mem.read(length)) #issue with consistency
#Dirty hack to allow for differences in read methods
#Read in blocks of 4 bytes
#Need to find a resolution
for x in range(0, length / 4):
sys.stdout.write(str(struct.pack('L', struct.unpack_from('L', mem, mem.tell())[0])))
mem.seek(4, os.SEEK_CUR)
#sys.stdout.write(mem.read(length)) #issue with consistency
elif(command == 't'):
sys.stdout.write(struct.pack('<H', mem.tell()))
sys.stdout.write(str(struct.pack('<H', mem.tell())))
elif(command == 'w'):
length = struct.unpack('<H', sys.stdin.read(2))[0];
mem.write(sys.stdin.read(length))
Expand Down

0 comments on commit 5bec547

Please sign in to comment.