@@ -112,28 +112,26 @@ int with_restarting_checks(FunctionWrapper<int(void)> operation,
112112{
113113 int ret = errorValue;
114114
115- on_error (
116- [&]() {
117- // Is a reset ongoing?
118- if (restartState.load () == 0 )
119- {
120- // We are not resetting.
121- userThreadCount++;
122- ret = operation ();
123- // The decrement will happen in the error handler if
124- // the thread crashes.
125- userThreadCount--;
126- return ;
127- }
128- // A reset is ongoing. yield to give a chance to the restart
129- // code to make some progress, in case applications are
130- // aggressively trying to re-open the socket.
131- yield ();
132- },
133- [&]() {
134- // Call the network stack error handler.
135- reset_network_stack_state (false /* this is not the IP thread */ );
136- });
115+ CHERIOT_DURING
116+ // Is a reset ongoing?
117+ if (restartState.load () == 0 )
118+ {
119+ // We are not resetting.
120+ userThreadCount++;
121+ ret = operation ();
122+ // The decrement will happen in the error handler if
123+ // the thread crashes.
124+ userThreadCount--;
125+ return ret;
126+ }
127+ // A reset is ongoing. yield to give a chance to the restart
128+ // code to make some progress, in case applications are
129+ // aggressively trying to re-open the socket.
130+ yield ();
131+ CHERIOT_HANDLER
132+ // Call the network stack error handler.
133+ reset_network_stack_state (false /* this is not the IP thread */ );
134+ CHERIOT_END_HANDLER
137135
138136 return ret;
139137}
@@ -152,18 +150,16 @@ int with_restarting_checks_driver(FunctionWrapper<int(void)> operation,
152150{
153151 int ret = errorValue;
154152
155- on_error (
156- [&]() {
157- userThreadCount++;
158- ret = operation ();
159- // The decrement will happen in the error handler if the thread
160- // crashes.
161- userThreadCount--;
162- },
163- [&]() {
164- // Call the network stack error handler.
165- reset_network_stack_state (false /* this is not the IP thread */ );
166- });
153+ CHERIOT_DURING
154+ userThreadCount++;
155+ ret = operation ();
156+ // The decrement will happen in the error handler if the thread
157+ // crashes.
158+ userThreadCount--;
159+ CHERIOT_HANDLER
160+ // Call the network stack error handler.
161+ reset_network_stack_state (false /* this is not the IP thread */ );
162+ CHERIOT_END_HANDLER
167163
168164 return ret;
169165}
0 commit comments