1
0

repl_opext.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. #ifdef HAVE_CONFIG_H
  39. # include <config.h>
  40. #endif
  41. /* supplier_operation_extension.c - replication extension to the Operation object
  42. */
  43. #include "repl.h"
  44. #include "repl5.h"
  45. /* ***** Supplier side ***** */
  46. /* supplier operation extension constructor */
  47. void* supplier_operation_extension_constructor (void *object, void *parent)
  48. {
  49. supplier_operation_extension *ext = (supplier_operation_extension*) slapi_ch_calloc (1, sizeof (supplier_operation_extension));
  50. if (ext == NULL)
  51. {
  52. slapi_log_error( SLAPI_LOG_PLUGIN, repl_plugin_name, "unable to create replication supplier operation extension - out of memory\n" );
  53. }
  54. else
  55. {
  56. ext->prevent_recursive_call= 0;
  57. }
  58. return ext;
  59. }
  60. /* supplier operation extension destructor */
  61. void supplier_operation_extension_destructor (void *ext,void *object, void *parent)
  62. {
  63. if (ext)
  64. {
  65. supplier_operation_extension *supext = (supplier_operation_extension *)ext;
  66. if (supext->operation_parameters)
  67. operation_parameters_free (&(supext->operation_parameters));
  68. if (supext->repl_gen)
  69. slapi_ch_free ((void**)&supext->repl_gen);
  70. slapi_ch_free((void **)&ext);
  71. }
  72. }
  73. /* ***** Consumer side ***** */
  74. /* consumer operation extension constructor */
  75. void* consumer_operation_extension_constructor (void *object, void *parent)
  76. {
  77. consumer_operation_extension *ext = (consumer_operation_extension*) slapi_ch_calloc (1, sizeof (consumer_operation_extension));
  78. if (ext == NULL)
  79. {
  80. slapi_log_error( SLAPI_LOG_PLUGIN, repl_plugin_name, "unable to create replication consumer operation extension - out of memory\n" );
  81. }
  82. if(object!=NULL && parent!=NULL)
  83. {
  84. consumer_connection_extension *connext;
  85. connext = (consumer_connection_extension *)repl_con_get_ext(REPL_CON_EXT_CONN, parent);
  86. if(NULL != connext)
  87. {
  88. /* We copy the Connection Replicated Session flag to the Replicated Operation flag */
  89. if (connext->isreplicationsession)
  90. {
  91. operation_set_flag((Slapi_Operation *)object,OP_FLAG_REPLICATED);
  92. }
  93. /* We set the Replication DN flag if session bound as replication dn */
  94. if (connext->is_legacy_replication_dn)
  95. {
  96. operation_set_flag((Slapi_Operation *)object, OP_FLAG_LEGACY_REPLICATION_DN);
  97. }
  98. }
  99. }
  100. else
  101. {
  102. /* (parent==NULL) for internal operations */
  103. PR_ASSERT(object!=NULL);
  104. }
  105. return ext;
  106. }
  107. /* consumer operation extension destructor */
  108. void consumer_operation_extension_destructor (void *ext,void *object, void *parent)
  109. {
  110. if (NULL != ext)
  111. {
  112. consumer_operation_extension *opext = (consumer_operation_extension *)ext;
  113. if (NULL != opext->search_referrals)
  114. {
  115. /* free them - search_referrals is currently unused, but
  116. free them using the obverse of the allocation method */
  117. opext->search_referrals = NULL;
  118. }
  119. slapi_ch_free((void **)&ext);
  120. }
  121. }