Open Source Telephony
 help / color / mirror / Atom feed
From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
To: ofono@ofono.org
Subject: Re: [PATCH_v2 1/4] gatppp: Add new contructor to use external fd
Date: Fri, 29 Apr 2011 15:39:04 +0200	[thread overview]
Message-ID: <4DBABF78.30106@linux.intel.com> (raw)
In-Reply-To: <4DBAB95A.9050104@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2468 bytes --]

Hi again Denis,

On 29/04/2011 15:12, Guillaume Zajac wrote:
> Hi Denis,
>
> On 28/04/2011 21:41, Denis Kenzior wrote:
>> Hi Guillaume,
>>
>>>>>>> +        /* create a channel for reading and writing to this
>>>>>>> interface */
>>>>>>> +        channel = g_io_channel_unix_new(fd);
>>>>>>> +    }
>>>>>> There's a small problem of symmetry here.  If IPCP is established
>>>>>> correctly, then the fd will eventually be closed by ppp_net.  
>>>>>> However,
>>>>>> if we never properly establish IPCP, then fd will not be closed.  
>>>>>> What
>>>>>> is actually expected by ConnMan?
>>>>>>
>>>>> In the case we don't properly establish the IPCP, ppp_disconnect 
>>>>> CB of
>>>>> emulator will be called.
>>>>> Then, we will call the release_private_network DBus method. This 
>>>>> method
>>>>> will close the fd if it is opened.
>>>>>
>>>> Again, we're writing a library.  We cannot assume some behavior 
>>>> external
>>>> to the library is going to save us.  So I really suggest we make 
>>>> closing
>>>> of the fd symmetric.
>>> So I will close the fd into g_at_ppp_unref() if it is>=0.
>>> I have also to close it if we fail to create the PPP server.
>>>
>> Right.  Your approach doesn't sound completely correct, but I will let
>> you figure this out.  Just make sure to close the fd in all 
>> circumstances.
>
> In looking the previous implementation in ppp_net_new(),
> there is just:
>
> fd = open("/dev/net/tun", ...);
> ...
> net->channel = g_io_channel_unix_new(fd);
>
> However, the fd is never closed when we do ppp_net_free()
> We just unref the net->channel
>
> So should we do in ppp_net_free() a:
> fd = g_io_channel_unix_get_fd(net->channel);
> close(fd);
> g_io_channel_unref(net->channel);
>
> Or maybe I miss something?

In fact I missed something :) , the g_io_channel_unref() is closing fd

>
> In the new implementation, in the case we don't establish the IPCP, we 
> still have the fd of ConnMan opened.
> ppp->net == NULL so in the g_at_ppp_unref() we can do:
>
> if (ppp->net)
>         ppp_net_free(ppp->net); /* We close the fd  like above */

We close it during unref.

> else {
>         if( fd >= 0)
>                 close(ppp->fd); /* We don't have established IPCP, we 
> need to close the fd from ConnMan */
>         }
>

We might need also to do:

ppp->fd = -1;

into ppp_ipcp_down_notify() just after ppp_net_free()


Kind regards,
Guillaume

  parent reply	other threads:[~2011-04-29 13:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-22 12:06 [PATCH_v2 0/4] Request private petwork creation to ConnMan Guillaume Zajac
2011-04-22 12:06 ` [PATCH_v2 1/4] gatppp: Add new contructor to use external fd Guillaume Zajac
2011-04-27  3:20   ` Denis Kenzior
2011-04-28 13:06     ` Guillaume Zajac
2011-04-28 14:44       ` Denis Kenzior
2011-04-28 15:17         ` Guillaume Zajac
2011-04-28 19:41           ` Denis Kenzior
2011-04-29 13:12             ` Guillaume Zajac
2011-04-29  8:52               ` Denis Kenzior
2011-04-29 13:39               ` Guillaume Zajac [this message]
2011-04-22 12:06 ` [PATCH_v2 2/4] emulator: add routine to request/release private network from ConnMan Guillaume Zajac
2011-04-27  3:25   ` Denis Kenzior
2011-04-28 13:29     ` Guillaume Zajac
2011-04-28 19:39       ` Denis Kenzior
2011-04-29 10:06         ` Guillaume Zajac
2011-04-29  8:59           ` Denis Kenzior
2011-04-29 14:35             ` Guillaume Zajac
2011-04-22 12:06 ` [PATCH_v2 3/4] connman: add plugin in oFono to request request/release private network Guillaume Zajac
2011-04-22 12:06 ` [PATCH_v2 4/4] Makefile: add connman plugin build Guillaume Zajac
2011-04-27  3:27   ` Denis Kenzior

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=4DBABF78.30106@linux.intel.com \
    --to=guillaume.zajac@linux.intel.com \
    --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