Exemplo n.º 1
0
/*
 * Create a new protocol instance.
 */
Repl_Protocol *
prot_new(Repl_Agmt *agmt, int protocol_state)
{
	Slapi_DN *replarea_sdn = NULL;
	Repl_Protocol *rp = (Repl_Protocol *)slapi_ch_calloc(1, sizeof(Repl_Protocol));

	rp->prp_incremental = rp->prp_total = rp->prp_active_protocol = NULL;
	if (protocol_state == STATE_PERFORMING_TOTAL_UPDATE)
	{
		rp->state = STATE_PERFORMING_TOTAL_UPDATE;
	}
	else
	{
		rp->state = STATE_PERFORMING_INCREMENTAL_UPDATE;
	}
	rp->next_state = STATE_PERFORMING_INCREMENTAL_UPDATE; 
	if ((rp->lock = PR_NewLock()) == NULL)
	{
		goto loser;
	}
	rp->agmt = agmt;
	rp->conn = NULL;
	/* Acquire the local replica object */
	replarea_sdn = agmt_get_replarea(agmt);
	rp->replica_object = replica_get_replica_from_dn(replarea_sdn);
	if (NULL == rp->replica_object)
	{
		/* Whoa, no local replica!?!? */
		slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name,
			"prot_new - %s: Unable to locate replica object for local replica %s\n",
			agmt_get_long_name(agmt),
			slapi_sdn_get_dn(replarea_sdn));
		goto loser;
	}

	if (get_agmt_agreement_type(agmt) == REPLICA_TYPE_MULTIMASTER)
	{
		rp->prp_incremental = private_protocol_factory(rp, PROTOCOL_5_INCREMENTAL);
		rp->prp_total = private_protocol_factory(rp, PROTOCOL_5_TOTAL);
		rp->delete_conn = conn_delete;
	} 
	else if  (get_agmt_agreement_type(agmt) == REPLICA_TYPE_WINDOWS)
	{
		rp->prp_incremental = private_protocol_factory(rp, PROTOCOL_WINDOWS_INCREMENTAL);
		rp->prp_total = private_protocol_factory(rp, PROTOCOL_WINDOWS_TOTAL);
		rp->delete_conn = windows_conn_delete;
	}
	/* XXXggood register callback handlers for entries updated, and
		schedule window enter/leave. */
	
	goto done;

loser:
	prot_delete(&rp);

done:
	slapi_sdn_free(&replarea_sdn);

	return rp;
}
Exemplo n.º 2
0
/*
 * Note: when we add the new object, we have a reference to it. We hold
 * on to this reference until the agreement is deleted (or until the
 * server is shut down).
 */
int
add_new_agreement(Slapi_Entry *e)
{
    int rc = 0;
    Repl_Agmt *ra = agmt_new_from_entry(e);
    Slapi_DN *replarea_sdn = NULL;
    Replica *replica = NULL;
    Object *repl_obj = NULL;
    Object *ro = NULL;

    /* tell search result handler callback this entry was not sent */
    if (ra == NULL)
        return 1;

    ro = object_new((void *)ra, agmt_delete);
    objset_add_obj(agmt_set, ro);
    object_release(ro); /* Object now owned by objset */

    /* get the replica for this agreement */
    replarea_sdn = agmt_get_replarea(ra);
    repl_obj = replica_get_replica_from_dn(replarea_sdn);
    slapi_sdn_free(&replarea_sdn);
    if (repl_obj) {
        replica = (Replica*)object_get_data (repl_obj);
    }

    rc = replica_start_agreement(replica, ra);

    if (repl_obj) object_release(repl_obj);

    return rc;
}
Exemplo n.º 3
0
int
repl_session_plugin_call_post_acquire_cb(const Repl_Agmt *ra, int is_total,
                                         const char *data_guid, const struct berval *data)
{
    int rc = 0;
    Slapi_DN *replarea = NULL;

    repl_session_plugin_post_acquire_cb thefunc =
        (_ReplSessionAPI && _ReplSessionAPI[REPL_SESSION_PLUGIN_POST_ACQUIRE_CB]) ?
        (repl_session_plugin_post_acquire_cb)_ReplSessionAPI[REPL_SESSION_PLUGIN_POST_ACQUIRE_CB] :
        NULL;

    if (thefunc) {
        replarea = agmt_get_replarea(ra);
        if (!replarea) {
            slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name,
                    "repl_session_plugin_call_post_acquire_cb - Aborted - No replication area\n");
            return 1;
        }
        rc = (*thefunc)(agmt_get_priv(ra), replarea, is_total, data_guid, data);
        slapi_sdn_free(&replarea);
    }

    return rc;
}
Exemplo n.º 4
0
void
repl_session_plugin_call_agmt_init_cb(Repl_Agmt *ra)
{
    void *cookie = NULL;
    Slapi_DN *replarea = NULL;
    repl_session_plugin_agmt_init_cb initfunc = NULL;

    slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name,
            "repl_session_plugin_call_agmt_init_cb - Begin\n");

    if (_ReplSessionAPI) {
        initfunc = (repl_session_plugin_agmt_init_cb)_ReplSessionAPI[REPL_SESSION_PLUGIN_AGMT_INIT_CB];
    }
    if (initfunc) {
        replarea = agmt_get_replarea(ra);
        if (!replarea) {
            slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name,
                    "repl_session_plugin_call_agmt_init_cb- Aborted - No replication area\n");
            return;
        }
        cookie = (*initfunc)(replarea);
        slapi_sdn_free(&replarea);
    }

    agmt_set_priv(ra, cookie);

    slapi_log_err(SLAPI_LOG_PLUGIN, repl_plugin_name, "repl_session_plugin_call_agmt_init_cb - End\n");

    return;
}
Exemplo n.º 5
0
Object* agmtlist_get_next_agreement_for_replica (Replica *r, Object *prev)
{
    const Slapi_DN *replica_root;
    Slapi_DN *agmt_root;
    Object *obj;
    Repl_Agmt *agmt;

    if (r == NULL)
    {
        /* ONREPL - log error */
        return NULL;
    }

    replica_root = replica_get_root(r);  

    if (prev)
        obj = objset_next_obj(agmt_set, prev);   
    else
        obj = objset_first_obj(agmt_set);
        
    while (obj)
    {
        agmt = (Repl_Agmt*)object_get_data (obj);
        PR_ASSERT (agmt);

        agmt_root = agmt_get_replarea(agmt);
        PR_ASSERT (agmt_root);

        if (slapi_sdn_compare (replica_root, agmt_root) == 0)
        {
            slapi_sdn_free (&agmt_root);
            return obj;
        }

        slapi_sdn_free (&agmt_root);
        obj = objset_next_obj(agmt_set, obj);
    }

    return NULL;
}
Exemplo n.º 6
0
void
repl_session_plugin_call_destroy_agmt_cb(const Repl_Agmt *ra)
{
    Slapi_DN *replarea = NULL;

    repl_session_plugin_destroy_agmt_cb thefunc =
        (_ReplSessionAPI && _ReplSessionAPI[REPL_SESSION_PLUGIN_DESTROY_AGMT_CB]) ?
        (repl_session_plugin_destroy_agmt_cb)_ReplSessionAPI[REPL_SESSION_PLUGIN_DESTROY_AGMT_CB] :
        NULL;

    if (thefunc) {
        replarea = agmt_get_replarea(ra);
        if (!replarea) {
            slapi_log_err(SLAPI_LOG_ERR, repl_plugin_name,
                    "repl_session_plugin_call_destroy_agmt_cb - Aborted - No replication area\n");
            return;
        }
        (*thefunc)(agmt_get_priv(ra), replarea);
        slapi_sdn_free(&replarea);
    }

    return;
}