repl_opext.c 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 "repl5.h"
  15. /* ***** Supplier side ***** */
  16. /* supplier operation extension constructor */
  17. void *
  18. supplier_operation_extension_constructor(void *object __attribute__((unused)), void *parent __attribute__((unused)))
  19. {
  20. supplier_operation_extension *ext = (supplier_operation_extension *)slapi_ch_calloc(1, sizeof(supplier_operation_extension));
  21. if (ext == NULL) {
  22. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "unable to create replication supplier operation extension - out of memory\n");
  23. } else {
  24. ext->prevent_recursive_call = 0;
  25. }
  26. return ext;
  27. }
  28. /* supplier operation extension destructor */
  29. void
  30. supplier_operation_extension_destructor(void *ext, void *object __attribute__((unused)), void *parent __attribute__((unused)))
  31. {
  32. if (ext) {
  33. supplier_operation_extension *supext = (supplier_operation_extension *)ext;
  34. if (supext->operation_parameters)
  35. operation_parameters_free(&(supext->operation_parameters));
  36. if (supext->repl_gen)
  37. slapi_ch_free((void **)&supext->repl_gen);
  38. slapi_ch_free((void **)&ext);
  39. }
  40. }
  41. /* ***** Consumer side ***** */
  42. /* consumer operation extension constructor */
  43. void *
  44. consumer_operation_extension_constructor(void *object, void *parent)
  45. {
  46. consumer_operation_extension *ext = (consumer_operation_extension *)slapi_ch_calloc(1, sizeof(consumer_operation_extension));
  47. if (ext == NULL) {
  48. slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "unable to create replication consumer operation extension - out of memory\n");
  49. }
  50. if (object != NULL && parent != NULL) {
  51. consumer_connection_extension *connext;
  52. connext = (consumer_connection_extension *)repl_con_get_ext(REPL_CON_EXT_CONN, parent);
  53. if (NULL != connext) {
  54. /* We copy the Connection Replicated Session flag to the Replicated Operation flag */
  55. if (connext->isreplicationsession) {
  56. operation_set_flag((Slapi_Operation *)object, OP_FLAG_REPLICATED);
  57. }
  58. }
  59. } else {
  60. /* (parent==NULL) for internal operations */
  61. PR_ASSERT(object != NULL);
  62. }
  63. return ext;
  64. }
  65. /* consumer operation extension destructor */
  66. void
  67. consumer_operation_extension_destructor(void *ext, void *object __attribute__((unused)), void *parent __attribute__((unused)))
  68. {
  69. if (NULL != ext) {
  70. consumer_operation_extension *opext = (consumer_operation_extension *)ext;
  71. if (NULL != opext->search_referrals) {
  72. /* free them - search_referrals is currently unused, but
  73. free them using the obverse of the allocation method */
  74. opext->search_referrals = NULL;
  75. }
  76. slapi_ch_free((void **)&ext);
  77. }
  78. }