repl_opext.c 2.8 KB

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