Adjust event queue front position upon expansion
This patch corrects the logic introduced in change
18839 which missed altering the index of the front
of the circular queue following its size expansion.
@@ -326,9 +326,17 @@ oc_process_post(struct oc_process *p, oc_process_event_t ev,
if (!events) {
oc_abort("Insufficient memory");
}
- int i;
- for (i = nevents; i < OC_PROCESS_NUMEVENTS; i++)
+ oc_process_num_events_t i = fevent, n = nevents - fevent, j = 0;
+ while (i < (OC_PROCESS_NUMEVENTS - n)) {
+ if (i < nevents) {
+ memcpy(&events[OC_PROCESS_NUMEVENTS - n + j], &events[i],
+ sizeof(struct event_data));
+ j++;
+ }
memset(&events[i], 0, sizeof(struct event_data));
+ i++;
+ }
+ fevent = OC_PROCESS_NUMEVENTS - n;
#else /* OC_DYNAMIC_ALLOCATION */
return OC_PROCESS_ERR_FULL;
#endif /* !OC_DYNAMIC_ALLOCATION */
