Skip to content
Snippets Groups Projects
Commit 96683602 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Merge branch '1.9' into 1.10

parents a25dfc68 c7c24f84
No related branches found
No related tags found
No related merge requests found
......@@ -40,8 +40,7 @@ fio_methods.read = function(self, buf, size)
end
if not ffi.istype(const_char_ptr_t, buf) then
size = buf or size
tmpbuf = buffer.IBUF_SHARED
tmpbuf:reset()
tmpbuf = buffer.ibuf()
buf = tmpbuf:reserve(size)
end
local res, err = internal.read(self.fh, buf, size)
......
......@@ -1067,6 +1067,76 @@ fio.unlink(tmpfile)
---
- true
...
tmp1 = fio.pathjoin(tmpdir, "tmp1")
---
...
tmp2= fio.pathjoin(tmpdir, "tmp2")
---
...
test_run:cmd("setopt delimiter ';'")
---
- true
...
function write_file(name, odd)
local fh = fio.open(name, { 'O_RDWR', 'O_TRUNC', 'O_CREAT' }, 0777)
if odd then
fh:write(string.rep('1', 100))
else
fh:write(string.rep('2', 100))
end
fh:write(name)
fh:seek(0)
return fh
end;
---
...
test_run:cmd("setopt delimiter ''");
---
- true
...
fh1 = write_file(tmp1)
---
...
fh2 = write_file(tmp2)
---
...
fiber = require('fiber')
---
...
digest = require('digest')
---
...
str = fh1:read()
---
...
fh1:seek(0)
---
- 0
...
hash = digest.crc32(str)
---
...
ch = fiber.channel(1)
---
...
f1 = fiber.create(function() str = fh1:read() ch:put(digest.crc32(str)) end)
---
...
f2 = fiber.create(function() str = fh2:read() end)
---
...
ch:get() == hash
---
- true
...
fio.unlink(tmp1)
---
- true
...
fio.unlink(tmp2)
---
- true
...
fio.rmdir(tmpdir)
---
- true
......
......@@ -342,4 +342,33 @@ fio.path.lexists(link)
fio.unlink(link)
fio.unlink(tmpfile)
tmp1 = fio.pathjoin(tmpdir, "tmp1")
tmp2= fio.pathjoin(tmpdir, "tmp2")
test_run:cmd("setopt delimiter ';'")
function write_file(name, odd)
local fh = fio.open(name, { 'O_RDWR', 'O_TRUNC', 'O_CREAT' }, 0777)
if odd then
fh:write(string.rep('1', 100))
else
fh:write(string.rep('2', 100))
end
fh:write(name)
fh:seek(0)
return fh
end;
test_run:cmd("setopt delimiter ''");
fh1 = write_file(tmp1)
fh2 = write_file(tmp2)
fiber = require('fiber')
digest = require('digest')
str = fh1:read()
fh1:seek(0)
hash = digest.crc32(str)
ch = fiber.channel(1)
f1 = fiber.create(function() str = fh1:read() ch:put(digest.crc32(str)) end)
f2 = fiber.create(function() str = fh2:read() end)
ch:get() == hash
fio.unlink(tmp1)
fio.unlink(tmp2)
fio.rmdir(tmpdir)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment