refactor GRil incoming bytes dispatching mechanism

Bug #1408239 reported by You-Sheng Yang on 2015-01-07
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ofono (Ubuntu)
You-Sheng Yang

Bug Description

GRil reads incoming bytes into ril_msg structure in function `read_fixed_record` in gril/gril.c. It's mostly working except it makes some assumptions that are not always true.

1. The `read_fixed_record` function calls `memmove` to copy data from ring_buffer, which follows that the whole parcel must not be wrapped. This is usually true because whenever a parcel is read, the ring_buffer rewind its in/out position markers to the beginning. However, if somehow rild transmits massive amount of parcels, or due to various reasons that the gio thread is not waked up in time and a lot of incoming data queued in kernel, then a parcel that spans across the boundary becomes very likely. This is actually the question raised in the comment:

  /* TODO: need to better understand how wrap works! */

With, the GrilIO part is immune from this problem but the `read_fixed_record` is still affected.

2. One should really avoid using ring_buffer APIs that involve its internal states. Ring buffer wrapping should not be a concern to other components whenever possible.

You-Sheng Yang (vicamo) wrote :
Changed in ofono (Ubuntu):
assignee: nobody → Vicamo Yang (vicamo)
Tony Espy (awe) on 2015-01-09
Changed in ofono (Ubuntu):
status: New → In Progress
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers