repl5_replsupplier.c 3.1 KB

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