repl5_replsupplier.c 2.9 KB

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