@@ -77,18 +77,14 @@ impl SyncClient {
7777 }
7878 Ok ( done) => {
7979 if done {
80- active. instructions . push ( Instruction :: CloseSyncStream { } ) ;
8180 * state = ClientState :: Idle ;
8281 }
8382 }
8483 } ;
8584
8685 Ok ( active. instructions )
8786 }
88- SyncControlRequest :: StopSyncStream => {
89- state. tear_down ( ) ?;
90- Ok ( Vec :: new ( ) )
91- }
87+ SyncControlRequest :: StopSyncStream => state. tear_down ( ) ,
9288 }
9389 }
9490}
@@ -99,13 +95,15 @@ enum ClientState {
9995}
10096
10197impl ClientState {
102- fn tear_down ( & mut self ) -> Result < ( ) , SQLiteError > {
98+ fn tear_down ( & mut self ) -> Result < Vec < Instruction > , SQLiteError > {
99+ let mut event = ActiveEvent :: new ( SyncEvent :: TearDown ) ;
100+
103101 if let ClientState :: IterationActive ( old) = self {
104- old. tear_down ( ) ?;
102+ old. run ( & mut event ) ?;
105103 } ;
106104
107105 * self = ClientState :: Idle ;
108- Ok ( ( ) )
106+ Ok ( event . instructions )
109107 }
110108}
111109
@@ -137,11 +135,6 @@ impl SyncIterationHandle {
137135 Ok ( event. instructions )
138136 }
139137
140- fn tear_down ( & mut self ) -> Result < ( ) , SQLiteError > {
141- self . run ( & mut ActiveEvent :: new ( SyncEvent :: TearDown ) ) ?;
142- Ok ( ( ) )
143- }
144-
145138 fn run ( & mut self , active : & mut ActiveEvent ) -> Result < bool , SQLiteError > {
146139 // Using a noop waker because the only event thing StreamingSyncIteration::run polls on is
147140 // the next incoming sync event.
@@ -156,6 +149,8 @@ impl SyncIterationHandle {
156149 Ok (
157150 if let Poll :: Ready ( result) = self . future . poll ( & mut context) {
158151 result?;
152+
153+ active. instructions . push ( Instruction :: CloseSyncStream { } ) ;
159154 true
160155 } else {
161156 false
0 commit comments