@@ -77,18 +77,14 @@ impl SyncClient {
77
77
}
78
78
Ok ( done) => {
79
79
if done {
80
- active. instructions . push ( Instruction :: CloseSyncStream { } ) ;
81
80
* state = ClientState :: Idle ;
82
81
}
83
82
}
84
83
} ;
85
84
86
85
Ok ( active. instructions )
87
86
}
88
- SyncControlRequest :: StopSyncStream => {
89
- state. tear_down ( ) ?;
90
- Ok ( Vec :: new ( ) )
91
- }
87
+ SyncControlRequest :: StopSyncStream => state. tear_down ( ) ,
92
88
}
93
89
}
94
90
}
@@ -99,13 +95,15 @@ enum ClientState {
99
95
}
100
96
101
97
impl 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
+
103
101
if let ClientState :: IterationActive ( old) = self {
104
- old. tear_down ( ) ?;
102
+ old. run ( & mut event ) ?;
105
103
} ;
106
104
107
105
* self = ClientState :: Idle ;
108
- Ok ( ( ) )
106
+ Ok ( event . instructions )
109
107
}
110
108
}
111
109
@@ -137,11 +135,6 @@ impl SyncIterationHandle {
137
135
Ok ( event. instructions )
138
136
}
139
137
140
- fn tear_down ( & mut self ) -> Result < ( ) , SQLiteError > {
141
- self . run ( & mut ActiveEvent :: new ( SyncEvent :: TearDown ) ) ?;
142
- Ok ( ( ) )
143
- }
144
-
145
138
fn run ( & mut self , active : & mut ActiveEvent ) -> Result < bool , SQLiteError > {
146
139
// Using a noop waker because the only event thing StreamingSyncIteration::run polls on is
147
140
// the next incoming sync event.
@@ -156,6 +149,8 @@ impl SyncIterationHandle {
156
149
Ok (
157
150
if let Poll :: Ready ( result) = self . future . poll ( & mut context) {
158
151
result?;
152
+
153
+ active. instructions . push ( Instruction :: CloseSyncStream { } ) ;
159
154
true
160
155
} else {
161
156
false
0 commit comments