]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/controls.c
ITS#8040 experimental Lazy Commit
[openldap] / servers / slapd / controls.c
index 7b285feabf3dad6ccfdb16b2b0c8cfafe0727979..7ca7d5899845fba79110822b1cccdd1ad18910a1 100644 (file)
@@ -51,6 +51,9 @@ static SLAP_CTRL_PARSE_FN parseSessionTracking;
 #ifdef SLAP_CONTROL_X_WHATFAILED
 static SLAP_CTRL_PARSE_FN parseWhatFailed;
 #endif
+#ifdef SLAP_CONTROL_X_LAZY_COMMIT
+static SLAP_CTRL_PARSE_FN parseLazyCommit;
+#endif
 
 #undef sc_mask /* avoid conflict with Irix 6.5 <sys/signal.h> */
 
@@ -226,6 +229,13 @@ static struct slap_control control_defs[] = {
                NULL, NULL,
                parseWhatFailed, LDAP_SLIST_ENTRY_INITIALIZER(next) },
 #endif
+#ifdef SLAP_CONTROL_X_LAZY_COMMIT
+       { LDAP_CONTROL_X_LAZY_COMMIT,
+               (int)offsetof(struct slap_control_ids, sc_lazyCommit),
+               SLAP_CTRL_GLOBAL|SLAP_CTRL_ACCESS|SLAP_CTRL_HIDE,
+               NULL, NULL,
+               parseLazyCommit, LDAP_SLIST_ENTRY_INITIALIZER(next) },
+#endif
 
        { NULL, 0, 0, NULL, 0, NULL, LDAP_SLIST_ENTRY_INITIALIZER(next) }
 };
@@ -2155,3 +2165,27 @@ done:;
        return rc;
 }
 #endif
+
+#ifdef SLAP_CONTROL_X_LAZY_COMMIT
+static int parseLazyCommit(
+       Operation *op,
+       SlapReply *rs,
+       LDAPControl *ctrl )
+{
+       if ( op->o_lazyCommit != SLAP_CONTROL_NONE ) {
+               rs->sr_text = "\"Lazy Commit?\" control specified multiple times";
+               return LDAP_PROTOCOL_ERROR;
+       }
+
+       if ( !BER_BVISNULL( &ctrl->ldctl_value )) {
+               rs->sr_text = "\"Lazy Commit?\" control value not absent";
+               return LDAP_PROTOCOL_ERROR;
+       }
+
+       op->o_lazyCommit = ctrl->ldctl_iscritical
+               ? SLAP_CONTROL_CRITICAL
+               : SLAP_CONTROL_NONCRITICAL;
+
+       return LDAP_SUCCESS;
+}
+#endif