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
4bcae57b
Commit
4bcae57b
authored
10 years ago
by
Dmitry E. Oboukhov
Browse files
Options
Downloads
Patches
Plain Diff
box.net.box[stable] uses new sockets and close socket properly. closes #457
parent
86fbbc56
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/box/lua/box_net.lua
+26
-21
26 additions, 21 deletions
src/box/lua/box_net.lua
with
26 additions
and
21 deletions
src/box/lua/box_net.lua
+
26
−
21
View file @
4bcae57b
...
...
@@ -302,16 +302,11 @@ box.net.box.new = function(host, port, reconnect_timeout)
return
true
end
local
sc
=
box
.
socket
.
tcp
()
if
sc
==
nil
then
self
:
fatal
(
"Can't create socket"
)
return
false
end
local
s
=
{
sc
:
connect
(
self
.
host
,
self
.
port
)
}
if
s
[
1
]
==
nil
then
self
:
fatal
(
"Can't connect to %s:%s: %s"
,
self
.
host
,
self
.
port
,
s
[
4
]
)
local
s
c
=
box
.
socket
.
tcp_
connect
(
self
.
host
,
self
.
port
)
if
s
c
==
nil
then
self
:
fatal
(
"Can't connect to %s:%s: %s"
,
self
.
host
,
self
.
port
,
box
.
errno
.
strerror
()
)
return
false
end
...
...
@@ -324,12 +319,14 @@ box.net.box.new = function(host, port, reconnect_timeout)
if
self
.
s
==
nil
then
return
end
local
res
=
{
self
.
s
:
recv
(
12
)
}
if
res
[
4
]
~=
nil
then
self
:
fatal
(
"Can't read socket: %s"
,
res
[
3
])
local
header
=
self
.
s
:
read
{
chunk
=
12
}
if
header
==
nil
then
self
:
fatal
(
"Can't read socket: %s"
,
box
.
errno
.
strerror
())
return
end
local
header
=
res
[
1
]
if
string.len
(
header
)
~=
12
then
self
:
fatal
(
"Unexpected eof while reading header from %s"
,
self
:
title
())
...
...
@@ -340,12 +337,12 @@ box.net.box.new = function(host, port, reconnect_timeout)
local
body
=
''
if
blen
>
0
then
res
=
{
self
.
s
:
recv
(
blen
)
}
if
res
[
4
]
~=
nil
then
self
:
fatal
(
"Error while reading socket: %s"
,
res
[
4
])
return
body
=
self
.
s
:
read
{
chunk
=
blen
}
if
body
==
nil
then
self
:
fatal
(
"Error while reading socket: %s"
,
box
.
errno
.
strerror
())
return
end
body
=
res
[
1
]
if
string.len
(
body
)
~=
blen
then
self
:
fatal
(
"Unexpected eof while reading body from %s"
,
self
:
title
())
...
...
@@ -402,9 +399,9 @@ box.net.box.new = function(host, port, reconnect_timeout)
request
=
self
.
processing
.
wch
:
get
(
1
)
end
if
self
.
s
~=
nil
and
request
~=
nil
then
local
res
=
{
self
.
s
:
send
(
request
)
}
if
res
[
1
]
~=
string.len
(
request
)
then
self
:
fatal
(
"Error while write socket: %s"
,
res
[
4
]
)
if
not
self
.
s
:
write
(
request
)
then
self
:
fatal
(
"Error while write socket: %s"
,
box
.
errno
.
strerror
()
)
end
request
=
nil
end
...
...
@@ -423,13 +420,16 @@ box.net.box.new = function(host, port, reconnect_timeout)
self
.
timeouted
=
{}
end
,
close
=
function
(
self
)
if
self
.
closed
then
errorf
(
"box.net.box: already closed (%s)"
,
self
:
title
())
end
self
.
closed
=
true
local
message
=
sprintf
(
'box.net.box: connection was closed (%s)'
,
self
:
title
())
self
.
process
=
function
()
error
(
message
)
end
...
...
@@ -438,6 +438,11 @@ box.net.box.new = function(host, port, reconnect_timeout)
-- wake up write fiber
self
.
processing
.
rch
:
put
(
true
,
0
)
self
.
processing
.
wch
:
put
(
true
,
0
)
if
self
.
s
~=
nil
then
self
.
s
:
close
()
self
.
s
=
nil
end
return
true
end
}
...
...
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