Beispiel #1
0
/* Get a lock, store pointer in global 'getlock'. */
static int getlock(enum ne_lock_scope scope, int depth)
{
    memset(&reslock, 0, sizeof(reslock));

    ne_fill_server_uri(i_session, &reslock.uri);
    reslock.uri.path = res;
    reslock.depth = depth;
    reslock.scope = scope;
    reslock.type = ne_locktype_write;
    reslock.timeout = 3600;
    reslock.owner = ne_strdup("litmus test suite");

    /* leave gotlock as NULL if the LOCK fails. */
    gotlock = NULL;

    ONMREQ("LOCK", res, ne_lock(i_session, &reslock));
    
    if (scope != reslock.scope) {
        t_context("requested lockscope not satisfied!  got %s, wanted %s",
                  scope == ne_lockscope_exclusive ? "exclusive" : "shared",
                  reslock.scope == ne_lockscope_exclusive ? 
                  "exclusive" : "shared");
        ne_unlock(i_session, &reslock);
        return FAIL;
    }    

    /* Take a copy of the lock. */
    gotlock = ne_lock_copy(&reslock);
    ne_lockstore_add(store, gotlock);

    return OK;
}
Beispiel #2
0
static int lock_collection(void)
{
    struct ne_lock dummy;
    char *tmp,*tmp2;
    
    CALL(getlock(ne_lockscope_exclusive, NE_DEPTH_INFINITE));
    
    PRECOND(gotlock);

    memcpy(&dummy, &reslock, sizeof(reslock));
    dummy.token = NULL;
    dummy.uri.path = collZ;
    dummy.owner = ne_strdup("litmus: owner lock");
    dummy.depth = NE_DEPTH_INFINITE;
    dummy.type = ne_locktype_write;
    dummy.scope = ne_lockscope_exclusive;
    
    ONNREQ2("LOCK on second collection for further tests", 
	    ne_lock(i_session, &dummy));
    gotlock = ne_lock_copy(&dummy);
    ne_lockstore_add(store, gotlock);

    /* Testing creation of directories under a collection */ 
    ONV(ne_mkcol(i_session, collX),
        ("MKCOL %s: %s", collX, ne_get_error(i_session)));
    ONV(ne_mkcol(i_session, collY),
        ("MKCOL %s: %s", collY, ne_get_error(i_session)));

    upload_foo("lockcoll/collX/temp");
    tmp = ne_concat(collY,"copy-temp",NULL);	
    ONV(ne_copy(i_session, 0, NE_DEPTH_INFINITE, res3,tmp),
	("collection COPY `%s' to `%s': %s", res2, tmp,
	 ne_get_error(i_session)));
    free(tmp);
    
    tmp2=ne_concat(collZ,"testing",NULL);
    ONV(ne_copy(i_session, 0, NE_DEPTH_INFINITE, res3,tmp2),
	("collection COPY `%s' to `%s': %s", res2, tmp2,
	 ne_get_error(i_session)));

    ne_free(res3);	
    res3 = ne_concat(i_path,"not-existing",NULL);

 
    /* change res to point to a normal resource for subsequent
     * {not_,}owner_modify tests */
    res = ne_concat(coll, "lockme.txt", NULL);
    return upload_foo("lockcoll/lockme.txt");
}
Beispiel #3
0
/* indirectly refresh the the collection lock */
static int indirect_refresh(void)
{
    struct ne_lock *indirect;

    PRECOND(gotlock);

    indirect = ne_lock_copy(gotlock);
    ne_free(indirect->uri.path);
    indirect->uri.path = ne_strdup(res);

    ONV(ne_lock_refresh(i_session, indirect),
        ("indirect refresh LOCK on %s via %s: %s",
         coll, res, ne_get_error(i_session)));

    ne_lock_destroy(indirect);

    return OK;    
}
Beispiel #4
0
/* Get a lock, store pointer in global 'getlock'. */
static int getlock(enum ne_lock_scope scope, int depth)
{
    memset(&reslock, 0, sizeof(reslock));

    ne_fill_server_uri(i_session, &reslock.uri);
    reslock.uri.path = res;
    reslock.depth = depth;
    reslock.scope = scope;
    reslock.type = ne_locktype_write;
    reslock.timeout = 3600;
    reslock.owner = ne_strdup("litmus test suite");

    /* leave gotlock as NULL if the LOCK fails. */
    gotlock = NULL;

    ONMREQ("LOCK", res, ne_lock(i_session, &reslock));
    
    /* Take a copy of the lock. */
    gotlock = ne_lock_copy(&reslock);
    ne_lockstore_add(store, gotlock);

    return OK;
}