aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/deadlock.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/deadlock.lua b/tests/deadlock.lua
new file mode 100644
index 0000000..8ccae89
--- /dev/null
+++ b/tests/deadlock.lua
@@ -0,0 +1,28 @@
1local lanes = require('lanes').configure()
2local linda = lanes.linda "deadlock_linda"
3
4local do_extra_stuff = true
5
6if do_extra_stuff then
7 -- just something to make send() succeed and receive() fail:
8 local payload = { lanes.require('socket').connect }
9
10 -- lane generator
11 local g = lanes.gen('*', function()
12 set_debug_threadname "deadlock_lane"
13 print("In lane 1:", table.unpack{pcall(linda.receive, linda, 'tmp')})
14 print("In lane 2:", table.unpack{pcall(linda.receive, linda, 'tmp')})
15 return 33, 55
16 end)
17
18 -- send payload twice
19 linda:send('tmp', payload, payload)
20 local h = g()
21 local err, stack = h:join()
22 print('we reach here and then deadlock', err, stack)
23end
24-- start lane
25
26-- wait some
27lanes.sleep(2)
28print('we never reach here') \ No newline at end of file