On Mon, Jun 9, 2014 at 9:56 PM, YAMAMOTO Takashi <yamam...@valinux.co.jp> wrote: >> On Mon, Jun 9, 2014 at 5:26 PM, YAMAMOTO Takashi <yamam...@valinux.co.jp> >> wrote: >>>> Add a macro to waiting until all ports supplied are connected. >>>> >>>> CC: Jarno Rajahalme <jrajaha...@nicira.com> >>>> Signed-off-by: Andy Zhou <az...@nicira.com> >>>> --- >>>> tests/ofproto-macros.at | 9 +++++++++ >>>> 1 file changed, 9 insertions(+) >>>> >>>> diff --git a/tests/ofproto-macros.at b/tests/ofproto-macros.at >>>> index b4b6dab..af1e4f8 100644 >>>> --- a/tests/ofproto-macros.at >>>> +++ b/tests/ofproto-macros.at >>>> @@ -123,3 +123,12 @@ m4_define([ADD_OF_PORTS], >>>> [ovs-vsctl m4_foreach([of_port], m4_cdr($@), >>>> [ \ >>>> -- add-port $1 p[]of_port -- set Interface p[]of_port type=dummy >>>> ofport_request=of_port])]) >>>> + >>>> +# WAIT_FOR_DUMMY_PORTS(NETDEV_DUMMY_PORT[, NETDEV_DUMMY_PORT...]) >>>> +# >>>> +# Wait until the netdev dummy ports are connected to each other >>>> +m4_define([WAIT_FOR_DUMMY_PORTS], \ >>>> + [m4_foreach([dummy_port], [$@], >>>> + [ \ >>>> + OVS_WAIT_WHILE([ovs-appctl netdev-dummy/conn-state dummy_port \ >>>> + | grep 'unknown\|disconnected'], [sleep 1])])]) >>> >>> why "sleep 1" here? >> >> Because ovs-appctl commands in general returns immediately. Without >> the sleep 1 here, >> it may be unnecessarily increase the load on vswitchd. >> >> Some system accepts sleep of a fractional seconds. I am not sure how >> portable they are. Do you >> know of a portable way? Sleeping for, say 0.1 seconds, should be ideal. > > iirc OVS_WAIT_WHILE internally do that.
Yes indeed. ovs_wait() internally sleeps. The first sleep is with 0.1 seconds. So fractional seconds are portable after all. Thanks for point this out. I will drop the 'sleep 1'. > > YAMAMOTO Takashi > >>> >>> YAMAMOTO Takashi >>> >>>> -- >>>> 1.9.1 >> _______________________________________________ >> dev mailing list >> dev@openvswitch.org >> http://openvswitch.org/mailman/listinfo/dev _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev