arehbein has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/33654 )
Change subject: osmo_io: Adapt osmo_io msg processing ......................................................................
osmo_io: Adapt osmo_io msg processing
- segm. callback semantics have been changed, this reflects those changes (e.g., the segm. callback will now change each message once read) - since the segm. callback can now pull headers, the length compared to the length expected from header data must be read after calling the segmentation callback
Related: OS#5753 Change-Id: I5ff2f1416f294ac84b4240fd96da4aa3255fb27b --- M src/core/osmo_io.c 1 file changed, 20 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/54/33654/1
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c index fdb9e32..c561583 100644 --- a/src/core/osmo_io.c +++ b/src/core/osmo_io.c @@ -223,29 +223,28 @@ */ static enum iofd_seg_act iofd_handle_segmentation(struct osmo_io_fd *iofd, struct msgb *msg, struct msgb **pending_out) { - int extra_len, received_len; + int extra_len, received_len_post_segm_cb; struct msgb *msg_pending;
- received_len = msgb_length(msg); - if (!iofd->io_ops.segmentation_cb) { *pending_out = NULL; return IOFD_SEG_ACT_HANDLE_ONE; }
int expected_len = iofd->io_ops.segmentation_cb(msg); + received_len_post_segm_cb = msgb_length(msg); if (expected_len == -EAGAIN) { goto defer; } else if (expected_len < 0) { /* Something is wrong, skip this msgb */ LOGPIO(iofd, LOGL_ERROR, "segmentation_cb returned error (%d), skipping msg of size %d\n", - expected_len, received_len); + expected_len, received_len_post_segm_cb); *pending_out = NULL; msgb_free(msg); return IOFD_SEG_ACT_DEFER; }
- extra_len = received_len - expected_len; + extra_len = received_len_post_segm_cb - expected_len; /* No segmentation needed, return the whole msgb */ if (extra_len == 0) { *pending_out = NULL;