bugfix: reset event_n to 0 when error on sp_wait