Attention is currently required from: arehbein, laforge, fixeria.
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bts/+/31533 )
Change subject: common: Have PCU socket connection use osmo_wqueue ......................................................................
Patch Set 9:
(2 comments)
File src/common/pcu_sock.c:
https://gerrit.osmocom.org/c/osmo-bts/+/31533/comment/3a377072_536f8195 PS6, Line 990: pcu_sock_close(state);
I think this was not yet addressed?
Not sure what you are talking about arehbein. pcu_sock_send() is not creating the sturct msgb, but the caller expects it to take ownsership of the object, hence it is the duty of pcu_sock_send() to make sure the object is always freed. Similary, osmo_wqueue_enqueue is expected to take ownsership of the message if it doesn't fail, that's what the documentation of the API states. Hence, it's pcu_sock_send() duty to free the object to avoid the leak.
https://gerrit.osmocom.org/c/osmo-bts/+/31533/comment/10d00429_f8c74f74 PS6, Line 1106: rc = osmo_wqueue_enqueue(&state->upqueue, m);
Thanks for the reference, I'm now returning `-errno` just in case `write()` causes `errno` to be `EB […]
No, that's wrong. write() returning -EBADF doesn't mean we should return it. -EBADF is a return code with a specific meaning the callback should return in case it frees the related object/ofd.
I wouldn't return -errno here in all cases, but rather return specific errnos based on what's needed, to avoid unexpected consequences (eg -EBADF forwarded from write() to the calle of thi function).