Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quasar-wayland
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
Jens Nolte
quasar-wayland
Commits
7d1e4826
Commit
7d1e4826
authored
3 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Improve connection error handling
parent
97a1e454
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Quasar/Wayland/Connection.hs
+17
-8
17 additions, 8 deletions
src/Quasar/Wayland/Connection.hs
with
17 additions
and
8 deletions
src/Quasar/Wayland/Connection.hs
+
17
−
8
View file @
7d1e4826
...
...
@@ -30,6 +30,10 @@ instance IsResourceManager (WaylandConnection s) where
instance
IsDisposable
(
WaylandConnection
s
)
where
toDisposable
connection
=
toDisposable
connection
.
resourceManager
data
SocketClosed
=
SocketClosed
deriving
stock
Show
deriving
anyclass
Exception
newWaylandConnection
::
forall
s
m
.
MonadResourceManager
m
=>
Callback
s
STM
I_wl_display
->
Socket
->
m
(
WaylandConnection
s
)
newWaylandConnection
wlDisplayCallback
socket
=
do
protocolStateVar
<-
liftIO
$
newTVarIO
$
initialProtocolState
wlDisplayCallback
...
...
@@ -48,8 +52,8 @@ newWaylandConnection wlDisplayCallback socket = do
registerDisposeAction
$
closeConnection
connection
runUnlimitedAsync
do
async
$
liftIO
$
waylandC
onnection
Send
Thread
connection
`
catchAll
`
\
ex
->
traceIO
(
displayException
ex
)
>>
void
(
dispose
resourceManager
)
async
$
liftIO
$
waylandC
onnection
Receive
Thread
connection
`
catchAll
`
\
ex
->
traceIO
(
displayException
ex
)
>>
void
(
dispose
resourceManager
)
c
onnectionThread
connection
$
sendThread
connection
c
onnectionThread
connection
$
receiveThread
connection
-- HACK to send first message (queued internally)
stepProtocol
connection
$
feedInput
""
...
...
@@ -68,21 +72,26 @@ stepProtocol connection step = liftIO do
Left
ex
->
throwM
(
ex
::
SomeException
)
Right
result
->
pure
result
connectionThread
::
MonadAsync
m
=>
WaylandConnection
s
->
IO
()
->
m
()
connectionThread
connection
work
=
async_
$
liftIO
$
work
`
catches
`
[
ignoreCancelTask
,
handleAll
]
where
ignoreCancelTask
=
Handler
(
throwM
::
CancelTask
->
IO
a
)
handleAll
=
Handler
(
\
(
ex
::
SomeException
)
->
traceIO
(
displayException
ex
)
>>
void
(
dispose
connection
))
waylandConnectionS
endThread
::
WaylandConnection
s
->
IO
()
waylandConnectionS
endThread
connection
=
forever
do
s
endThread
::
WaylandConnection
s
->
IO
()
s
endThread
connection
=
forever
do
bytes
<-
atomically
$
takeTMVar
connection
.
outboxVar
traceIO
$
"Sending
data:
"
<>
show
(
BSL
.
length
bytes
)
<>
" bytes"
traceIO
$
"Sending "
<>
show
(
BSL
.
length
bytes
)
<>
" bytes"
SocketL
.
sendAll
connection
.
socket
bytes
waylandConnectionR
eceiveThread
::
WaylandConnection
s
->
IO
()
waylandConnectionR
eceiveThread
connection
=
forever
do
r
eceiveThread
::
WaylandConnection
s
->
IO
()
r
eceiveThread
connection
=
forever
do
bytes
<-
Socket
.
recv
connection
.
socket
4096
when
(
BS
.
length
bytes
==
0
)
do
fail
"
Socket
is c
losed
"
throwM
Socket
C
losed
traceIO
$
"Received "
<>
show
(
BS
.
length
bytes
)
<>
" bytes"
...
...
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