From: Marcel Holtmann <marcel@holtmann.org>
To: ofono@ofono.org
Subject: RE: [PATCHv2 1/2] stemodem: Add RTNL functionality managing CAIF Network Interfaces.
Date: Tue, 02 Nov 2010 06:03:26 +0100 [thread overview]
Message-ID: <1288674206.3322.165.camel@aeonflux> (raw)
In-Reply-To: <81C3A93C17462B4BBD7E272753C105791945A4F406@EXDCVYMBSTM005.EQ1STM.local>
[-- Attachment #1: Type: text/plain, Size: 2770 bytes --]
Hi Sjur,
> > You don't really have to play this append/remove game. You can just
> > append it after send_rtnl_req succeed. The read goes via the mainloop
> > anyway and we are a single threaded program. So the order is
> > guaranteed.
>
> I'm not sure about this. I need to keep track of what
> connection-id I assign to the CAIF Interface in the request and what
> interface name and interface index I get for that connection id
> in the RTNL response.
> This mapping between network interface and connection id is used
> when PDP Contexts are activated. The append/remove game provides me
> with the request-response mapping.
I know what you are trying to protect here, but what I am saying is that
just appending the struct to the list after you send it (and evaluated
its error code) is just fine.
You don't need to append it first, send the message, check error and in
case of an error remove it again.
The nature of single-thread application using a mainloop and where input
is driven by that mainloop, ensures that you will only receive the reply
to your message after you added it to the list. Even if that is done
after you send it.
So while it is fine to append the structure to the list for further
tracking, you should just do it after you send the message and it
succeeded and be done with it.
And while we are at it. Essentially you also need to use asynchronous
and non-blocking watch driven sending of your message in the first
place. I did forget to check if you open the RTNL socket non-blocking,
but you should be doing that.
> > > +struct rtnl_rsp_param {
> > > + int result;
> > > + gpointer user_data;
> > > + char ifname[IF_NAMESIZE];
> > > + int ifindex;
> > > +};
> > > +
> > > +struct rtnl_req_param {
> > > + void (*callback)(struct rtnl_rsp_param *param);
> > > + gpointer user_data;
> > > + int type;
> > > + int conn_id;
> > > + gboolean loop_enabled;
> > > +};
> > > +
> > > +extern int caif_rtnl_create_interface(struct rtnl_req_param *req);
> > > +extern int caif_rtnl_delete_interface(int ifid);
> >
> > I am not really sold on this param stuct thingy btw. Why do you need
> > them? Just proper input params and output params for the callback
> > handler would do them same. Won't they?
>
> Yes, I could do that. But in that case I would prefer to typedef the
> response function to simplify create function's signature. Otherwise
> I think the create function's signature gets too complex.
typedef for function callbacks are just fine. I have no problem with
that at all.
I am not set in stone here, but for something this simple, it seems to
me that the two structs is a bit of overhead and complexity that we
could avoid.
Regards
Marcel
next prev parent reply other threads:[~2010-11-02 5:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-28 14:03 [PATCH 1/4] stemodem: Add rtnl header file Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-10-28 14:03 ` [PATCH 2/4] stemodem: Add RTNL functionality for CAIF Netw Interface Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-11-01 16:59 ` Marcel Holtmann
2010-11-01 20:17 ` [PATCHv2 1/2] stemodem: Add RTNL functionality managing CAIF Network Interfaces Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-11-01 21:04 ` Marcel Holtmann
2010-11-01 22:42 ` Sjur BRENDELAND
2010-11-02 5:03 ` Marcel Holtmann [this message]
2010-11-03 10:55 ` Sjur BRENDELAND
2010-11-03 13:41 ` Marcel Holtmann
2010-11-09 16:56 ` Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-11-01 20:17 ` [PATCHv2 2/2] stemodem: Update gprs-context to use rtnl to create/remove interfaces Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-10-28 14:04 ` [PATCH 3/4] stemodem: Update gprs-context to use rtnl Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-10-28 14:04 ` [PATCH 4/4] stemodem: Add rtnl to Makefile Sjur =?unknown-8bit?q?Br=C3=A6ndeland?=
2010-11-01 16:54 ` Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1288674206.3322.165.camel@aeonflux \
--to=marcel@holtmann.org \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox