On Wed, Sep 3, 2014 at 1:24 PM, Alex Wang <al...@nicira.com> wrote: > After discussing with Pravin offline, it is good to use first get the > reference > and then access the 'port->netdev' for pmd check. > > So, use a nested if statement: > > @@ -1864,20 +1874,27 @@ pmd_load_queues(struct pmd_thread *f, > index = 0; > > CMAP_FOR_EACH (port, node, &f->dp->ports) { > - if (netdev_is_pmd(port->netdev)) { > - int i; > - > - for (i = 0; i < netdev_n_rxq(port->netdev); i++) { > - if ((index % dp->n_pmd_threads) == id) { > - poll_list = xrealloc(poll_list, sizeof *poll > - > - port_ref(port); > - poll_list[poll_cnt].port = port; > - poll_list[poll_cnt].rx = port->rxq[i]; > - poll_cnt++; > + /* Calls port_try_ref() to prevent the main thread > + * from deleting the port. */ > + if (port_try_ref(port)) { > + if (netdev_is_pmd(port->netdev)) { > + int i; > + > + for (i = 0; i < netdev_n_rxq(port->netdev); i++) > + if ((index % dp->n_pmd_threads) == id) { > + poll_list = xrealloc(poll_list, > + sizeof *poll_list * (pol > + > + port_ref(port); > + poll_list[poll_cnt].port = port; > + poll_list[poll_cnt].rx = port->rxq[i]; > + poll_cnt++; > + } > + index++; > } > - index++; > } > + /* Unrefs the port_try_ref(). */ > + port_unref(port); > } > > Will apply to master soon,
Thanks. _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev