repl_opext.c 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright 2001 Sun Microsystems, Inc.
  3. * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
  4. * All rights reserved.
  5. * END COPYRIGHT BLOCK **/
  6. /* supplier_operation_extension.c - replication extension to the Operation object
  7. */
  8. #include "repl.h"
  9. #include "repl5.h"
  10. /* ***** Supplier side ***** */
  11. /* JCMREPL -> PINAKIxxx The interface to the referral stuff is not correct */
  12. void ref_array_dup_free(void *the_copy); /* JCMREPL - should be #included */
  13. /* supplier operation extension constructor */
  14. void* supplier_operation_extension_constructor (void *object, void *parent)
  15. {
  16. supplier_operation_extension *ext = (supplier_operation_extension*) slapi_ch_calloc (1, sizeof (supplier_operation_extension));
  17. if (ext == NULL)
  18. {
  19. slapi_log_error( SLAPI_LOG_PLUGIN, repl_plugin_name, "unable to create replication supplier operation extension - out of memory\n" );
  20. }
  21. else
  22. {
  23. ext->prevent_recursive_call= 0;
  24. }
  25. return ext;
  26. }
  27. /* supplier operation extension destructor */
  28. void supplier_operation_extension_destructor (void *ext,void *object, void *parent)
  29. {
  30. if (ext)
  31. {
  32. supplier_operation_extension *supext = (supplier_operation_extension *)ext;
  33. if (supext->operation_parameters)
  34. operation_parameters_free (&(supext->operation_parameters));
  35. if (supext->repl_gen)
  36. slapi_ch_free ((void**)&supext->repl_gen);
  37. slapi_ch_free((void **)&ext);
  38. }
  39. }
  40. /* ***** Consumer side ***** */
  41. /* consumer operation extension constructor */
  42. void* consumer_operation_extension_constructor (void *object, void *parent)
  43. {
  44. consumer_operation_extension *ext = (consumer_operation_extension*) slapi_ch_calloc (1, sizeof (consumer_operation_extension));
  45. if (ext == NULL)
  46. {
  47. slapi_log_error( SLAPI_LOG_PLUGIN, repl_plugin_name, "unable to create replication consumer operation extension - out of memory\n" );
  48. }
  49. if(object!=NULL && parent!=NULL)
  50. {
  51. consumer_connection_extension *connext;
  52. connext = (consumer_connection_extension *)repl_con_get_ext(REPL_CON_EXT_CONN, parent);
  53. if(NULL != connext)
  54. {
  55. /* We copy the Connection Replicated Session flag to the Replicated Operation flag */
  56. if (connext->isreplicationsession)
  57. {
  58. operation_set_flag((Slapi_Operation *)object,OP_FLAG_REPLICATED);
  59. }
  60. /* We set the Replication DN flag if session bound as replication dn */
  61. if (connext->is_legacy_replication_dn)
  62. {
  63. operation_set_flag((Slapi_Operation *)object, OP_FLAG_LEGACY_REPLICATION_DN);
  64. }
  65. }
  66. }
  67. else
  68. {
  69. /* (parent==NULL) for internal operations */
  70. PR_ASSERT(object!=NULL);
  71. }
  72. return ext;
  73. }
  74. /* consumer operation extension destructor */
  75. void consumer_operation_extension_destructor (void *ext,void *object, void *parent)
  76. {
  77. if (NULL != ext)
  78. {
  79. consumer_operation_extension *opext = (consumer_operation_extension *)ext;
  80. if (NULL != opext->search_referrals)
  81. {
  82. ref_array_dup_free(opext->search_referrals); /* JCMREPL - undefined */
  83. opext->search_referrals = NULL;
  84. }
  85. slapi_ch_free((void **)&ext);
  86. }
  87. }