repl_opext.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. /* supplier_operation_extension.c - replication extension to the Operation object
  13. */
  14. #include "repl.h"
  15. #include "repl5.h"
  16. /* ***** Supplier side ***** */
  17. /* supplier operation extension constructor */
  18. void* supplier_operation_extension_constructor (void *object, void *parent)
  19. {
  20. supplier_operation_extension *ext = (supplier_operation_extension*) slapi_ch_calloc (1, sizeof (supplier_operation_extension));
  21. if (ext == NULL)
  22. {
  23. slapi_log_error(SLAPI_LOG_PLUGIN, LOG_DEBUG, repl_plugin_name, "unable to create replication supplier operation extension - out of memory\n" );
  24. }
  25. else
  26. {
  27. ext->prevent_recursive_call= 0;
  28. }
  29. return ext;
  30. }
  31. /* supplier operation extension destructor */
  32. void supplier_operation_extension_destructor (void *ext,void *object, void *parent)
  33. {
  34. if (ext)
  35. {
  36. supplier_operation_extension *supext = (supplier_operation_extension *)ext;
  37. if (supext->operation_parameters)
  38. operation_parameters_free (&(supext->operation_parameters));
  39. if (supext->repl_gen)
  40. slapi_ch_free ((void**)&supext->repl_gen);
  41. slapi_ch_free((void **)&ext);
  42. }
  43. }
  44. /* ***** Consumer side ***** */
  45. /* consumer operation extension constructor */
  46. void* consumer_operation_extension_constructor (void *object, void *parent)
  47. {
  48. consumer_operation_extension *ext = (consumer_operation_extension*) slapi_ch_calloc (1, sizeof (consumer_operation_extension));
  49. if (ext == NULL)
  50. {
  51. slapi_log_error(SLAPI_LOG_PLUGIN, LOG_DEBUG, repl_plugin_name, "unable to create replication consumer operation extension - out of memory\n" );
  52. }
  53. if(object!=NULL && parent!=NULL)
  54. {
  55. consumer_connection_extension *connext;
  56. connext = (consumer_connection_extension *)repl_con_get_ext(REPL_CON_EXT_CONN, parent);
  57. if(NULL != connext)
  58. {
  59. /* We copy the Connection Replicated Session flag to the Replicated Operation flag */
  60. if (connext->isreplicationsession)
  61. {
  62. operation_set_flag((Slapi_Operation *)object,OP_FLAG_REPLICATED);
  63. }
  64. /* We set the Replication DN flag if session bound as replication dn */
  65. if (connext->is_legacy_replication_dn)
  66. {
  67. operation_set_flag((Slapi_Operation *)object, OP_FLAG_LEGACY_REPLICATION_DN);
  68. }
  69. }
  70. }
  71. else
  72. {
  73. /* (parent==NULL) for internal operations */
  74. PR_ASSERT(object!=NULL);
  75. }
  76. return ext;
  77. }
  78. /* consumer operation extension destructor */
  79. void consumer_operation_extension_destructor (void *ext,void *object, void *parent)
  80. {
  81. if (NULL != ext)
  82. {
  83. consumer_operation_extension *opext = (consumer_operation_extension *)ext;
  84. if (NULL != opext->search_referrals)
  85. {
  86. /* free them - search_referrals is currently unused, but
  87. free them using the obverse of the allocation method */
  88. opext->search_referrals = NULL;
  89. }
  90. slapi_ch_free((void **)&ext);
  91. }
  92. }