Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
a19c5584
Commit
a19c5584
authored
10 years ago
by
ocelot-inc
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of
https://github.com/tarantool/tarantool
parents
2856006a
80201ffb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/lua/bsdsocket.lua
+16
-15
16 additions, 15 deletions
src/lua/bsdsocket.lua
test/box/bsdsocket.result
+74
-0
74 additions, 0 deletions
test/box/bsdsocket.result
test/box/bsdsocket.test.lua
+26
-0
26 additions, 0 deletions
test/box/bsdsocket.test.lua
with
116 additions
and
15 deletions
src/lua/bsdsocket.lua
+
16
−
15
View file @
a19c5584
...
@@ -560,29 +560,27 @@ end
...
@@ -560,29 +560,27 @@ end
local
function
readline_check
(
self
,
eols
,
limit
)
local
function
readline_check
(
self
,
eols
,
limit
)
local
rbuf
=
self
.
rbuf
local
rbuf
=
self
.
rbuf
if
rbuf
==
nil
then
return
nil
end
if
string.len
(
rbuf
)
==
0
then
if
string.len
(
rbuf
)
==
0
then
return
nil
return
nil
end
end
local
shortest
local
shortest
for
i
,
eol
in
pairs
(
eols
)
do
for
i
,
eol
in
ipairs
(
eols
)
do
if
string.len
(
rbuf
)
>=
string.len
(
eol
)
then
local
data
=
string.match
(
rbuf
,
"^(.-"
..
eol
..
")"
)
local
data
=
string.match
(
rbuf
,
"^(.-"
..
eol
..
")"
)
if
data
~=
nil
then
if
data
~=
nil
then
if
string.len
(
data
)
>
limit
then
if
string.len
(
data
)
>
limit
then
data
=
string.sub
(
data
,
1
,
limit
)
data
=
string.sub
(
data
,
1
,
limit
)
end
end
if
shortest
==
nil
then
if
shortest
==
nil
then
shortest
=
data
shortest
=
data
elseif
#
shortest
>
#
data
then
elseif
#
shortest
>
#
data
then
shortest
=
data
shortest
=
data
end
end
end
end
end
end
end
if
shortest
==
nil
and
#
rbuf
>=
limit
then
return
string.sub
(
rbuf
,
1
,
limit
)
end
return
shortest
return
shortest
end
end
...
@@ -592,6 +590,9 @@ local function readline(self, limit, eol, timeout)
...
@@ -592,6 +590,9 @@ local function readline(self, limit, eol, timeout)
end
end
self
.
_errno
=
nil
self
.
_errno
=
nil
if
limit
==
0
then
return
''
end
local
data
=
readline_check
(
self
,
eol
,
limit
)
local
data
=
readline_check
(
self
,
eol
,
limit
)
if
data
~=
nil
then
if
data
~=
nil
then
self
.
rbuf
=
string.sub
(
self
.
rbuf
,
string.len
(
data
)
+
1
)
self
.
rbuf
=
string.sub
(
self
.
rbuf
,
string.len
(
data
)
+
1
)
...
...
This diff is collapsed.
Click to expand it.
test/box/bsdsocket.result
+
74
−
0
View file @
a19c5584
...
@@ -1377,6 +1377,80 @@ server:close()
...
@@ -1377,6 +1377,80 @@ server:close()
---
---
- true
- true
...
...
-- gh-658: socket:read() incorrectly handles size and delimiter together
body = "a 10\nb 15\nabc"
---
...
remaining = #body
---
...
--# setopt delimiter ';'
server = socket.tcp_server('unix/', path, function(s)
s:write(body)
s:read(100500)
end);
---
...
--# setopt delimiter ''
client = socket.tcp_connect('unix/', path)
---
...
buf = client:read({ size = remaining, delimiter = "[\r\n]+"})
---
...
buf == "a 10\n"
---
- true
...
remaining = remaining - #buf
---
...
buf = client:read({ size = remaining, delimiter = "[\r\n]+"})
---
...
buf == "b 15\n"
---
- true
...
remaining = remaining - #buf
---
...
buf = client:read({ size = remaining, delimiter = "[\r\n]+"})
---
...
buf == "abc"
---
- true
...
remaining = remaining - #buf
---
...
remaining == 0
---
- true
...
buf = client:read({ size = remaining, delimiter = "[\r\n]+"})
---
...
buf == ""
---
- true
...
buf = client:read({ size = remaining, delimiter = "[\r\n]+"})
---
...
buf == ""
---
- true
...
client:close()
---
- true
...
server:close()
---
- true
...
-- Test that socket is closed on GC
-- Test that socket is closed on GC
s = socket('AF_UNIX', 'SOCK_STREAM', 'ip')
s = socket('AF_UNIX', 'SOCK_STREAM', 'ip')
---
---
...
...
This diff is collapsed.
Click to expand it.
test/box/bsdsocket.test.lua
+
26
−
0
View file @
a19c5584
...
@@ -462,6 +462,32 @@ client = socket.tcp_connect('unix/', path)
...
@@ -462,6 +462,32 @@ client = socket.tcp_connect('unix/', path)
client
:
read
{
line
=
{
"
\n\n
"
,
"
\r\n\r\n
"
}
}
client
:
read
{
line
=
{
"
\n\n
"
,
"
\r\n\r\n
"
}
}
server
:
close
()
server
:
close
()
-- gh-658: socket:read() incorrectly handles size and delimiter together
body
=
"a 10\nb 15\nabc"
remaining
=
#
body
--# setopt delimiter ';'
server
=
socket
.
tcp_server
(
'unix/'
,
path
,
function
(
s
)
s
:
write
(
body
)
s
:
read
(
100500
)
end
);
--# setopt delimiter ''
client
=
socket
.
tcp_connect
(
'unix/'
,
path
)
buf
=
client
:
read
({
size
=
remaining
,
delimiter
=
"[\r\n]+"
})
buf
==
"a 10\n"
remaining
=
remaining
-
#
buf
buf
=
client
:
read
({
size
=
remaining
,
delimiter
=
"[\r\n]+"
})
buf
==
"b 15\n"
remaining
=
remaining
-
#
buf
buf
=
client
:
read
({
size
=
remaining
,
delimiter
=
"[\r\n]+"
})
buf
==
"abc"
remaining
=
remaining
-
#
buf
remaining
==
0
buf
=
client
:
read
({
size
=
remaining
,
delimiter
=
"[\r\n]+"
})
buf
==
""
buf
=
client
:
read
({
size
=
remaining
,
delimiter
=
"[\r\n]+"
})
buf
==
""
client
:
close
()
server
:
close
()
-- Test that socket is closed on GC
-- Test that socket is closed on GC
s
=
socket
(
'AF_UNIX'
,
'SOCK_STREAM'
,
'ip'
)
s
=
socket
(
'AF_UNIX'
,
'SOCK_STREAM'
,
'ip'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment