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
2022fe24
Commit
2022fe24
authored
11 years ago
by
Dmitry E. Oboukhov
Browse files
Options
Downloads
Patches
Plain Diff
More debug information in box.net.box messages.
parent
0452b9aa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/box/lua/box_net.lua
+31
-9
31 additions, 9 deletions
src/box/lua/box_net.lua
test/box/net.box.result
+2
-2
2 additions, 2 deletions
test/box/net.box.result
with
33 additions
and
11 deletions
src/box/lua/box_net.lua
+
31
−
9
View file @
2022fe24
-- box_net.lua (internal file)
(
function
()
local
function
sprintf
(
fmt
,
...
)
return
string.format
(
fmt
,
...
)
end
local
function
printf
(
fmt
,
...
)
print
(
sprintf
(
fmt
,
...
))
end
local
function
errorf
(
fmt
,
...
)
error
(
sprintf
(
fmt
,
...
))
end
box
.
net
=
{
--
-- The idea of box.net.box implementation is that
...
...
@@ -130,8 +136,7 @@ box.net = {
end
end
error
(
string.format
(
'Can not find "box.net.box.%s" function'
,
name
))
errorf
(
'Can not find "box.net.box.%s" function'
,
name
)
end
});
...
...
@@ -197,6 +202,12 @@ box.net.box.new = function(host, port, reconnect_timeout)
reconnect_timeout
=
reconnect_timeout
,
closed
=
false
,
timeouted
=
{},
title
=
function
(
self
)
return
sprintf
(
'%s:%s'
,
tostring
(
self
.
host
),
tostring
(
self
.
port
))
end
,
processing
=
{
last_sync
=
0
,
next_sync
=
function
(
self
)
...
...
@@ -255,6 +266,7 @@ box.net.box.new = function(host, port, reconnect_timeout)
-- timeout
if
res
==
nil
then
self
.
timeouted
[
sync
]
=
true
if
op
==
65280
then
return
false
else
...
...
@@ -277,7 +289,7 @@ box.net.box.new = function(host, port, reconnect_timeout)
return
box
.
unpack
(
'R'
,
body
)
end
else
error
(
res
[
2
])
error
f
(
'%s: %s'
,
self
:
title
(),
res
[
2
])
end
end
,
...
...
@@ -316,7 +328,8 @@ box.net.box.new = function(host, port, reconnect_timeout)
end
local
header
=
res
[
1
]
if
string.len
(
header
)
~=
12
then
self
:
fatal
(
"Unexpected eof while reading header"
)
self
:
fatal
(
"Unexpected eof while reading header from %s"
,
self
:
title
())
return
end
...
...
@@ -331,7 +344,8 @@ box.net.box.new = function(host, port, reconnect_timeout)
end
body
=
res
[
1
]
if
string.len
(
body
)
~=
blen
then
self
:
fatal
(
"Unexpected eof while reading body"
)
self
:
fatal
(
"Unexpected eof while reading body from %s"
,
self
:
title
())
return
end
end
...
...
@@ -360,7 +374,12 @@ box.net.box.new = function(host, port, reconnect_timeout)
if
self
.
processing
[
sync
]
~=
nil
then
self
.
processing
[
sync
]:
put
({
true
,
resp
},
0
)
else
print
(
"Unexpected response "
,
sync
)
if
self
.
timeouted
[
sync
]
then
printf
(
"Timeouted response from %s"
,
self
:
title
())
else
printf
(
"Unexpected response %s from %s"
,
sync
,
self
:
title
())
end
end
end
...
...
@@ -390,21 +409,23 @@ box.net.box.new = function(host, port, reconnect_timeout)
end
,
fatal
=
function
(
self
,
message
,
...
)
message
=
s
t
rin
g.forma
t
(
message
,
...
)
message
=
s
p
rint
f
(
message
,
...
)
self
.
s
=
nil
for
sync
,
ch
in
pairs
(
self
.
processing
)
do
if
type
(
sync
)
==
'number'
then
ch
:
put
({
false
,
message
},
0
)
end
end
self
.
timeouted
=
{}
end
,
close
=
function
(
self
)
if
self
.
closed
then
error
(
"box.net.box: already closed
"
)
error
f
(
"box.net.box: already closed
(%s)"
,
self
:
title
()
)
end
self
.
closed
=
true
local
message
=
'box.net.box: connection was closed'
local
message
=
sprintf
(
'box.net.box: connection was closed (%s)'
,
self
:
title
())
self
.
process
=
function
()
error
(
message
)
end
...
...
@@ -426,4 +447,5 @@ box.net.box.new = function(host, port, reconnect_timeout)
return
remote
end
end
)()
-- vim: set et ts=4 sts
This diff is collapsed.
Click to expand it.
test/box/net.box.result
+
2
−
2
View file @
2022fe24
...
...
@@ -173,11 +173,11 @@ lua remote:close()
...
lua remote:close()
---
error: '[string "-- box_net.lua (internal file)..."]:
404
: box.net.box: already closed'
error: '[string "-- box_net.lua (internal file)..."]:
7
: box.net.box: already closed
(localhost:33013)
'
...
lua remote:ping()
---
error: '[string "-- box_net.lua (internal file)..."]:40
9
: box.net.box: connection was closed'
error: '[string "-- box_net.lua (internal file)..."]:4
3
0: box.net.box: connection was closed
(localhost:33013)
'
...
lua box.space[0]:truncate()
---
...
...
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