-/* Asynchronous version of the above. Has the extra overhead of
- * spawning a new thread, so should be used sparingly. */
-struct async_req {
- pthread_t tid;
- struct ls *ls;
-
- bool req_valid;
- struct ls_req expected;
- struct ls_req actual;
-};
-
-static void *get_request_thread(void *arg)
-{
- struct async_req *async_req = arg;
- async_req->req_valid =
- ls_get_request(async_req->ls, &async_req->actual);
-
- return NULL;
-}
-
-static struct async_req *
-get_and_check_request_async(struct ls *ls, struct lease_handle *expected_lease,
- enum ls_req_type expected_type)
-
-{
- struct async_req *req = malloc(sizeof(struct async_req));
- ck_assert_ptr_ne(req, NULL);
-
- *req = (struct async_req){
- .ls = ls,
- .expected =
- {
- .lease_handle = expected_lease,
- .type = expected_type,
- },
- };
-
- int ret = pthread_create(&req->tid, NULL, get_request_thread, req);
- ck_assert_int_eq(ret, 0);
-
- return req;
-}
-
-static void check_async_req_result(struct async_req *req)
-{
-
- pthread_join(req->tid, NULL);
- ck_assert_int_eq(req->req_valid, true);
- check_request(&req->actual, req->expected.lease_handle,
- req->expected.type);
- free(req);
-}
-