[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: OpenLDAP cache




Jong wrote:



Hello,

Can someone, please, clarify a few things for me, I just can't figure it out fast enough by myself :(

1. If the (*be->be_add) operation was successful - entry is released using be_entry_release_w( be, e ); otherwise - entry_free(e);

I hope I'm not mistaken here. But what should be done after delete and search?

If I performed an internal search (like SASL code does), stored the entries returned by be->be_search in an array and then deleted them one by one - what has to be done to release them and free the memory (in case of success and failure)?

The callback function for sending the entry looks like this:

int xps_send_search_entry (
   Backend    *be,
   Connection    *conn,
   Operation    *op,
   Entry    *e,
   AttributeName    *attrs,
   int        attrsonly,
   LDAPControl **ctrls
)
{
   int num;

Debug(LDAP_DEBUG_TRACE, "===> xps_send_search_entry: xps_send_search_entry dn = %s\n",e->e_name.bv_val, 0, 0);

   for ( num = 0; xps_e_level1[num] != NULL; num++ );

xps_e_level1 = (Entry **)ch_realloc( xps_e_level1,
sizeof( Entry *) * ( num + 2 ) );
xps_e_level1[num] = e;
xps_e_level1[num+1] = NULL;
Debug(LDAP_DEBUG_TRACE, "<=== xps_send_search_entry\n",0, 0, 0);
return LDAP_SUCCESS;
}


Next, I'm trying to delete them:

   for ( i = 0; xps_e_level1[i]!= 0; i++)
       {
           if ( (*be->be_delete)( be, conn, op, &xps_e_level2[i]->e_name,
                        &xps_e_level2[i]->e_nname ) != 0 )
           {
               return LDAP_UNWILLING_TO_PERFORM;
           }

After that I need to free those entries (do I, or is it done anyway after the operation is finished? This doesn't seem like the right answer)



The callback function needs to duplicate entries, because the entries are not guaranteed to reside in memory - a backend may not have the entry cache, caches may be replaced etc.

Thank you. Could you advise me on whats the best way to do that?
Simply write a copy_entry routine which will copy the memory contents(I think you don't have one yet)
Use entry2str() and str2entry()


Any help or info would be really appreciated,
thanks in advance,
Mikhail