repl5_replsupplier.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. /* repl5_replsupplier.c */
  13. /*
  14. A replsupplier is an object that knows how to manage outbound replication
  15. for one consumer.
  16. Methods:
  17. init()
  18. configure()
  19. start()
  20. stop()
  21. destroy()
  22. status()
  23. notify()
  24. */
  25. #include "slapi-plugin.h"
  26. #include "repl5.h"
  27. typedef struct repl_supplier {
  28. PRUint32 client_change_count; /* # of client-supplied changes */
  29. PRUint32 repl_change_count; /* # of replication updates */
  30. PRLock *lock;
  31. } repl_supplier;
  32. static void repl_supplier_free(Repl_Supplier **rsp);
  33. /*
  34. * Create and initialize this replsupplier object.
  35. */
  36. Repl_Supplier *
  37. replsupplier_init(Slapi_Entry *e)
  38. {
  39. Repl_Supplier *rs;
  40. if ((rs = (Repl_Supplier *)slapi_ch_malloc(sizeof(Repl_Supplier))) == NULL)
  41. {
  42. goto loser;
  43. }
  44. if ((rs->lock = PR_NewLock()) == NULL)
  45. {
  46. goto loser;
  47. }
  48. return rs;
  49. loser:
  50. repl_supplier_free(&rs);
  51. return NULL;
  52. }
  53. static void
  54. repl_supplier_free(Repl_Supplier **rsp)
  55. {
  56. if (NULL != rsp)
  57. {
  58. Repl_Supplier *rs = *rsp;
  59. if (NULL != rs)
  60. {
  61. if (NULL != rs->lock)
  62. {
  63. PR_DestroyLock(rs->lock);
  64. rs->lock = NULL;
  65. }
  66. slapi_ch_free((void **)rsp);
  67. }
  68. }
  69. }
  70. /*
  71. * Configure a repl_supplier object.
  72. */
  73. void
  74. replsupplier_configure(Repl_Supplier *rs, Slapi_PBlock *pb)
  75. {
  76. PR_ASSERT(NULL != rs);
  77. }
  78. /*
  79. * Start a repl_supplier object. This means that it's ok for
  80. * the repl_supplier to begin normal replication duties. It does
  81. * not necessarily mean that a replication session will occur
  82. * immediately.
  83. */
  84. void
  85. replsupplier_start(Repl_Supplier *rs)
  86. {
  87. PR_ASSERT(NULL != rs);
  88. }
  89. /*
  90. * Stop a repl_supplier object. This causes any active replication
  91. * sessions to be stopped ASAP, and puts the repl_supplier into a
  92. * stopped state. No additional replication activity will occur
  93. * until the replsupplier_start() function is called.
  94. */
  95. void
  96. replsupplier_stop(Repl_Supplier *rs)
  97. {
  98. PR_ASSERT(NULL != rs);
  99. }
  100. /*
  101. * Destroy a repl_supplier object. The object will be stopped, if it
  102. * is not already stopped.
  103. */
  104. void
  105. replsupplier_destroy(Repl_Supplier **rsp)
  106. {
  107. Repl_Supplier *rs;
  108. PR_ASSERT(NULL != rsp && NULL != *rsp);
  109. rs = *rsp;
  110. slapi_ch_free((void **)rsp);
  111. }
  112. /*
  113. * This method should be called by the repl_bos whenever it determines
  114. * that a change to the replicated area serviced by this repl_supplier
  115. * has occurred. This gives the repl_supplier a chance to implement a
  116. * scheduling policy.
  117. */
  118. void
  119. replsupplier_notify(Repl_Supplier *rs, PRUint32 eventmask)
  120. {
  121. PR_ASSERT(NULL != rs);
  122. }
  123. /*
  124. * This method is used to obtain the status of this particular
  125. * repl_supplier object. Eventually it will return some object containing
  126. * status information. For now, it's just a placeholder function.
  127. */
  128. PRUint32
  129. replsupplier_get_status(Repl_Supplier *rs)
  130. {
  131. PR_ASSERT(NULL != rs);
  132. return 0;
  133. }