Hi Jose, 

In my system, p2p-wlan0-x is the interface name for p2p group operation. x is the integer value and is increasing for every new p2p group creation.
< P2P connection >
- P2PDevice.GONegotiationRequest is arrived on wlan0. 
- After calling "Connect", the new interface for p2p group operation is created on wpa-supplicant.
- WPS.Event is arrived on p2p-wlan0-x interface.
  (wifi->p2p_connecting in wps_event() is false and is_p2p_connecting() is true.)

< wps sta pbc connection >
- WPS.Event is arrrived on wlan0 interface.

The second idea is good, but it looks better checking p2p connecting. :)

Regards,
Eunok


2016-08-30 18:18 GMT+09:00 Jose Blanquicet <blanquicet@gmail.com>:
Hi Eunok Lee,

Thanks for your feedback.

> I applied the changes to my local source code(based on connman 1.29) for
> testing, and got some issue.
> When trying to establish p2p connection for using Miracast, it's failed.
> Though, the issue has gone with the below change.
> I'm not sure if this issue occurs only on connman 1.29, but would like to
> share this issue to you.
>
> --- a/connman/plugins/wifi.c
> +++ b/connman/plugins/wifi.c
> @@ -3183,7 +3183,7 @@ static void wps_event(GSupplicantInterface *interface,
>         struct wifi_data *wifi = g_supplicant_interface_get_data(interface);
>
>         /* Do nothing here for P2P Connections */
> -       if (wifi->p2p_connecting)
> +       if (is_p2p_connecting())
>                 return;
>
>         switch (state) {

is_p2p_connecting() checks if any interface has started a p2p
connection, instead what I did by checking the value of
wifi->p2p_connecting is to check if the specific interface on which
the event has arrived has started a p2p connection. Therefore, if for
you the current implementation does not work, it makes me think that
in your system the wpa_supplicant has been configured to create a
separated interface for p2p group operations, right? Although the
creation of that separated interface is the default behavior of the
wpa_supplicant there are many drives that do not support it, for
example my driver does not, so I did not test the patch with such a
configuration, sorry about that :(.

I think your proposed solution could have problems when WPS and P2P
are running concurrently in different interfaces, because the fact
that P2P is also connecting on any interface will result in the
discard of all the events, even the ones related to WPS which we do
not want to discard. I will study the following two ideas, the first
one is to check only in the original P2P interface if P2P is
connection instead of doing on all the interfaces. On the other hand,
a second idea could be to define a "wps_connecting" flag, doing so we
can check if WPS is connecting instead of check if p2p is connection.
Suggestion/Comments?

> And it looks like every dbus_malloc0 needs to check if it's NULL and return
> -ENOMEM. :)

You are right. In fact, I will move to glib memory functions as Tomasz
suggested in order to not introduce more inconsistency because of the
mixed used of glib and dbus.

Regards,

Jose Blanquicet