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
364be3b3
Commit
364be3b3
authored
10 years ago
by
Konstantin Osipov
Browse files
Options
Downloads
Patches
Plain Diff
A fix and a test case for gh-125: fiber cancel by numeric id.
Update the user guide.
parent
67b45d23
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
doc/user/stored-procedures.xml
+20
-0
20 additions, 0 deletions
doc/user/stored-procedures.xml
src/lua/init.cc
+21
-0
21 additions, 0 deletions
src/lua/init.cc
test/box/fiber.result
+15
-0
15 additions, 0 deletions
test/box/fiber.result
test/box/fiber.test
+6
-0
6 additions, 0 deletions
test/box/fiber.test
with
62 additions
and
0 deletions
doc/user/stored-procedures.xml
+
20
−
0
View file @
364be3b3
...
...
@@ -2623,6 +2623,26 @@ procedures.
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis
role=
"lua"
xml:id=
"box.fiber.kill"
>
box.fiber.kill(
<replaceable>
id
</replaceable>
)
</emphasis>
</term>
<listitem>
<para>
Locate a fiber by its numeric id and cancel it. In
other words, combines
<emphasis
role=
"lua"
>
box.fiber.find()
</emphasis>
and
<emphasis
role=
"lua"
>
box.fiber.cancel()
</emphasis>
into one
</para>
<para>
Parameters:
<code>
id
</code>
= the id of the fiber to be cancelled.
</para>
<para>
Possible errors: the specified fiber does not exist or does not permit cancel.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<emphasis
role=
"lua"
xml:id=
"box.fiber.testcancel"
>
box.fiber.testcancel()
</emphasis>
...
...
This diff is collapsed.
Click to expand it.
src/lua/init.cc
+
21
−
0
View file @
364be3b3
...
...
@@ -917,6 +917,26 @@ lbox_fiber_cancel(struct lua_State *L)
return
0
;
}
/**
* Running and suspended fibers can be cancelled.
* Zombie fibers can't.
*/
static
int
lbox_fiber_kill
(
struct
lua_State
*
L
)
{
if
(
lua_gettop
(
L
)
!=
1
)
luaL_error
(
L
,
"fiber.kill(): bad arguments"
);
int
fid
=
lua_tointeger
(
L
,
-
1
);
struct
fiber
*
f
=
fiber_find
(
fid
);
if
(
f
==
NULL
)
luaL_error
(
L
,
"fiber.kill(): fiber not found"
);
if
(
!
(
f
->
flags
&
FIBER_USER_MODE
))
luaL_error
(
L
,
"fiber.kill(): subject fiber does "
"not permit cancel"
);
fiber_cancel
(
f
);
return
0
;
}
/**
* Check if this current fiber has been cancelled and
* throw an exception if this is the case.
...
...
@@ -947,6 +967,7 @@ static const struct luaL_reg fiberlib[] = {
{
"id"
,
lbox_fiber_id
},
{
"find"
,
lbox_fiber_find
},
{
"cancel"
,
lbox_fiber_cancel
},
{
"kill"
,
lbox_fiber_kill
},
{
"testcancel"
,
lbox_fiber_testcancel
},
{
"create"
,
lbox_fiber_create
},
{
"resume"
,
lbox_fiber_resume
},
...
...
This diff is collapsed.
Click to expand it.
test/box/fiber.result
+
15
−
0
View file @
364be3b3
No preview for this file type
This diff is collapsed.
Click to expand it.
test/box/fiber.test
+
6
−
0
View file @
364be3b3
...
...
@@ -107,3 +107,9 @@ exec admin "lua f:resume()"
exec
admin
"lua fib_id = box.fiber.wrap(testfun):id()"
exec
admin
"lua box.fiber.find(fib_id):cancel()"
exec
admin
"lua box.fiber.find(fib_id)"
# gh-125 box.fiber.cancel() by numeric id
exec
admin
"lua function y() print('started') while true do box.replace(0, 'test', os.time()) box.fiber.sleep(0.001) end end"
exec
admin
"lua f = box.fiber.wrap(y)"
exec
admin
"lua box.fiber.kill(f:id())"
exec
admin
"lua while box.fiber.status(f) ~= 'dead' do box.fiber.sleep(0.01) end"
exec
admin
"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