@@ -174,8 +174,8 @@ static void replay_save_event(Event *event)
174
174
{
175
175
if (replay_mode != REPLAY_MODE_PLAY ) {
176
176
/* put the event into the file */
177
- replay_put_event ( EVENT_ASYNC );
178
- replay_put_byte ( event -> event_kind );
177
+ g_assert ( event -> event_kind < REPLAY_ASYNC_COUNT );
178
+ replay_put_event ( EVENT_ASYNC + event -> event_kind );
179
179
180
180
/* save event-specific data */
181
181
switch (event -> event_kind ) {
@@ -220,14 +220,10 @@ void replay_save_events(void)
220
220
static Event * replay_read_event (void )
221
221
{
222
222
Event * event ;
223
- if (replay_state .read_event_kind == -1 ) {
224
- replay_state .read_event_kind = replay_get_byte ();
225
- replay_state .read_event_id = -1 ;
226
- replay_check_error ();
227
- }
223
+ ReplayAsyncEventKind event_kind = replay_state .data_kind - EVENT_ASYNC ;
228
224
229
225
/* Events that has not to be in the queue */
230
- switch (replay_state . read_event_kind ) {
226
+ switch (event_kind ) {
231
227
case REPLAY_ASYNC_EVENT_BH :
232
228
case REPLAY_ASYNC_EVENT_BH_ONESHOT :
233
229
if (replay_state .read_event_id == -1 ) {
@@ -236,17 +232,17 @@ static Event *replay_read_event(void)
236
232
break ;
237
233
case REPLAY_ASYNC_EVENT_INPUT :
238
234
event = g_new0 (Event , 1 );
239
- event -> event_kind = replay_state . read_event_kind ;
235
+ event -> event_kind = event_kind ;
240
236
event -> opaque = replay_read_input_event ();
241
237
return event ;
242
238
case REPLAY_ASYNC_EVENT_INPUT_SYNC :
243
239
event = g_new0 (Event , 1 );
244
- event -> event_kind = replay_state . read_event_kind ;
240
+ event -> event_kind = event_kind ;
245
241
event -> opaque = 0 ;
246
242
return event ;
247
243
case REPLAY_ASYNC_EVENT_CHAR_READ :
248
244
event = g_new0 (Event , 1 );
249
- event -> event_kind = replay_state . read_event_kind ;
245
+ event -> event_kind = event_kind ;
250
246
event -> opaque = replay_event_char_read_load ();
251
247
return event ;
252
248
case REPLAY_ASYNC_EVENT_BLOCK :
@@ -256,18 +252,17 @@ static Event *replay_read_event(void)
256
252
break ;
257
253
case REPLAY_ASYNC_EVENT_NET :
258
254
event = g_new0 (Event , 1 );
259
- event -> event_kind = replay_state . read_event_kind ;
255
+ event -> event_kind = event_kind ;
260
256
event -> opaque = replay_event_net_load ();
261
257
return event ;
262
258
default :
263
- error_report ("Unknown ID %d of replay event" ,
264
- replay_state .read_event_kind );
259
+ error_report ("Unknown ID %d of replay event" , event_kind );
265
260
exit (1 );
266
261
break ;
267
262
}
268
263
269
264
QTAILQ_FOREACH (event , & events_list , events ) {
270
- if (event -> event_kind == replay_state . read_event_kind
265
+ if (event -> event_kind == event_kind
271
266
&& (replay_state .read_event_id == -1
272
267
|| replay_state .read_event_id == event -> id )) {
273
268
break ;
@@ -276,26 +271,23 @@ static Event *replay_read_event(void)
276
271
277
272
if (event ) {
278
273
QTAILQ_REMOVE (& events_list , event , events );
279
- } else {
280
- return NULL ;
281
274
}
282
275
283
- /* Read event-specific data */
284
-
285
276
return event ;
286
277
}
287
278
288
279
/* Called with replay mutex locked */
289
280
void replay_read_events (void )
290
281
{
291
282
g_assert (replay_mutex_locked ());
292
- while (replay_state .data_kind == EVENT_ASYNC ) {
283
+ while (replay_state .data_kind >= EVENT_ASYNC
284
+ && replay_state .data_kind <= EVENT_ASYNC_LAST ) {
293
285
Event * event = replay_read_event ();
294
286
if (!event ) {
295
287
break ;
296
288
}
297
289
replay_finish_event ();
298
- replay_state .read_event_kind = -1 ;
290
+ replay_state .read_event_id = -1 ;
299
291
replay_run_event (event );
300
292
301
293
g_free (event );
@@ -304,7 +296,7 @@ void replay_read_events(void)
304
296
305
297
void replay_init_events (void )
306
298
{
307
- replay_state .read_event_kind = -1 ;
299
+ replay_state .read_event_id = -1 ;
308
300
}
309
301
310
302
void replay_finish_events (void )
0 commit comments