Sasha Khapyorsky wrote:
On 23:51 Thu 30 Oct     , Yevgeny Kliteynik wrote:
Sure, why not. That way the memory would be freed faster.

Patch?

Sasha


I can do something like the following patch, but I have
some strange feeling that I'm missing something...
Can there be some flow that would cause lft_buf to be
freed while not all the lft blocks were received yet,
and then remaining blocks might change switch->lft
(after the switch->lft_buf was already freed)?
I can't think of any particular example, just a general
concern...

-- Yevgeny

Free lft_buf when newly received lft block
makes switch's lft identical to lft_buf.

Signed-off-by: Yevgeny Kliteynik <[EMAIL PROTECTED]>
---
 opensm/include/opensm/osm_switch.h |    7 +++++++
 opensm/opensm/osm_ucast_mgr.c      |    7 -------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/opensm/include/opensm/osm_switch.h 
b/opensm/include/opensm/osm_switch.h
index f06931c..af8a50e 100644
--- a/opensm/include/opensm/osm_switch.h
+++ b/opensm/include/opensm/osm_switch.h
@@ -729,6 +729,13 @@ osm_switch_set_lft_block(IN osm_switch_t * const p_sw,
                return IB_INVALID_PARAMETER;

        memcpy(&p_sw->lft[lid_start], p_block, IB_SMP_DATA_SIZE);
+
+       if (p_sw->lft_buf &&
+           !memcmp(p_sw->lft, p_sw->lft_buf, IB_LID_UCAST_END_HO + 1)) {
+               free(p_sw->lft_buf);
+               p_sw->lft_buf = NULL;
+       }
+
        return IB_SUCCESS;
 }
 /*
diff --git a/opensm/opensm/osm_ucast_mgr.c b/opensm/opensm/osm_ucast_mgr.c
index 175817c..7f1a816 100644
--- a/opensm/opensm/osm_ucast_mgr.c
+++ b/opensm/opensm/osm_ucast_mgr.c
@@ -399,13 +399,6 @@ int osm_ucast_mgr_set_fwd_table(IN osm_ucast_mgr_t * const 
p_mgr,
                goto Exit;
        }

-       if (!p_sw->need_update &&
-           !memcmp(p_sw->lft, p_sw->lft_buf, IB_LID_UCAST_END_HO + 1)) {
-               free(p_sw->lft_buf);
-               p_sw->lft_buf = NULL;
-               goto Exit;
-       }
-
        for (block_id_ho = 0;
             osm_switch_get_lft_block(p_sw, block_id_ho, block);
             block_id_ho++) {
--
1.5.1.4



_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to