io: fixed some missing stream locks
io: add some assertions for stream locking
Merge pull request #519 from promovicz/fix-stream-locking

Fix some missing stream locking