Lines Matching refs:ao

34 static libxl__ao *ao_nested_root(libxl__ao *ao);
36 static void ao__check_destroy(libxl_ctx *ctx, libxl__ao *ao);
356 static int time_register_abortable(libxl__ao *ao, libxl__ev_time *ev) in time_register_abortable() argument
358 ev->abrt.ao = ao; in time_register_abortable()
363 int libxl__ev_time_register_abs(libxl__ao *ao, libxl__ev_time *ev, in libxl__ev_time_register_abs() argument
375 rc = time_register_abortable(ao, ev); in libxl__ev_time_register_abs()
392 int libxl__ev_time_register_rel(libxl__ao *ao, libxl__ev_time *ev, in libxl__ev_time_register_rel() argument
404 rc = time_register_abortable(ao, ev); in libxl__ev_time_register_rel()
887 int libxl__ev_devstate_wait(libxl__ao *ao, libxl__ev_devstate *ds, in libxl__ev_devstate_wait() argument
898 ds->w.ao = ao; in libxl__ev_devstate_wait()
978 int libxl__domaindeathcheck_start(libxl__ao *ao, in libxl__domaindeathcheck_start() argument
987 dc->abrt.ao = ao; in libxl__domaindeathcheck_start()
1404 LOG(DEBUG,"ao %p: progress report: callback aop=%p", aop->ao, aop); in egc_run_callbacks()
1408 assert(aop->ao->magic == LIBXL__AO_MAGIC); in egc_run_callbacks()
1409 aop->ao->progress_reports_outstanding--; in egc_run_callbacks()
1410 libxl__ao_complete_check_progress_reports(egc, aop->ao); in egc_run_callbacks()
1414 libxl__ao *ao, *ao_tmp; in egc_run_callbacks() local
1415 LIBXL_TAILQ_FOREACH_SAFE(ao, &egc->aos_for_callback, in egc_run_callbacks()
1417 LIBXL_TAILQ_REMOVE(&egc->aos_for_callback, ao, entry_for_callback); in egc_run_callbacks()
1418 LOG(DEBUG,"ao %p: completion callback", ao); in egc_run_callbacks()
1419 ao->how.callback(CTX, ao->rc, ao->how.u.for_callback); in egc_run_callbacks()
1421 ao->notified = 1; in egc_run_callbacks()
1422 ao__check_destroy(CTX, ao); in egc_run_callbacks()
1813 static void ao__manip_enter(libxl__ao *ao) in ao__manip_enter() argument
1815 assert(ao->manip_refcnt < INT_MAX); in ao__manip_enter()
1816 ao->manip_refcnt++; in ao__manip_enter()
1819 static void ao__manip_leave(libxl_ctx *ctx, libxl__ao *ao) in ao__manip_leave() argument
1821 assert(ao->manip_refcnt > 0); in ao__manip_leave()
1822 ao->manip_refcnt--; in ao__manip_leave()
1823 ao__check_destroy(ctx, ao); in ao__manip_leave()
1826 static void ao__check_destroy(libxl_ctx *ctx, libxl__ao *ao) in ao__check_destroy() argument
1828 if (!ao->manip_refcnt && ao->notified) { in ao__check_destroy()
1829 assert(ao->complete); in ao__check_destroy()
1830 libxl__ao__destroy(ctx, ao); in ao__check_destroy()
1834 void libxl__ao__destroy(libxl_ctx *ctx, libxl__ao *ao) in libxl__ao__destroy() argument
1837 if (!ao) return; in libxl__ao__destroy()
1838 LOG(DEBUG,"ao %p: destroy",ao); in libxl__ao__destroy()
1839 libxl__poller_put(ctx, ao->poller); in libxl__ao__destroy()
1840 ao->magic = LIBXL__AO_MAGIC_DESTROYED; in libxl__ao__destroy()
1841 libxl__free_all(&ao->gc); in libxl__ao__destroy()
1842 free(ao); in libxl__ao__destroy()
1845 void libxl__ao_create_fail(libxl__ao *ao) in libxl__ao_create_fail() argument
1848 LOG(DEBUG,"ao %p: create fail",ao); in libxl__ao_create_fail()
1849 assert(ao->magic == LIBXL__AO_MAGIC); in libxl__ao_create_fail()
1850 assert(ao->in_initiator); in libxl__ao_create_fail()
1851 assert(!ao->complete); in libxl__ao_create_fail()
1852 assert(!ao->progress_reports_outstanding); in libxl__ao_create_fail()
1853 assert(!ao->aborting); in libxl__ao_create_fail()
1854 LIBXL_LIST_REMOVE(ao, inprogress_entry); in libxl__ao_create_fail()
1855 libxl__ao__destroy(CTX, ao); in libxl__ao_create_fail()
1858 libxl__gc *libxl__ao_inprogress_gc(libxl__ao *ao) in libxl__ao_inprogress_gc() argument
1860 assert(ao); in libxl__ao_inprogress_gc()
1861 assert(ao->magic == LIBXL__AO_MAGIC); in libxl__ao_inprogress_gc()
1862 assert(!ao->complete); in libxl__ao_inprogress_gc()
1863 return &ao->gc; in libxl__ao_inprogress_gc()
1866 void libxl__ao_complete(libxl__egc *egc, libxl__ao *ao, int rc) in libxl__ao_complete() argument
1869 LOG(DEBUG,"ao %p: complete, rc=%d",ao,rc); in libxl__ao_complete()
1870 assert(ao->magic == LIBXL__AO_MAGIC); in libxl__ao_complete()
1871 assert(!ao->complete); in libxl__ao_complete()
1872 assert(!ao->nested_root); in libxl__ao_complete()
1873 assert(!ao->nested_progeny); in libxl__ao_complete()
1874 ao->complete = 1; in libxl__ao_complete()
1875 ao->rc = rc; in libxl__ao_complete()
1876 LIBXL_LIST_REMOVE(ao, inprogress_entry); in libxl__ao_complete()
1877 libxl__ao_complete_check_progress_reports(egc, ao); in libxl__ao_complete()
1880 static bool ao_work_outstanding(libxl__ao *ao) in ao_work_outstanding() argument
1890 return !ao->complete || ao->progress_reports_outstanding; in ao_work_outstanding()
1893 void libxl__ao_complete_check_progress_reports(libxl__egc *egc, libxl__ao *ao) in libxl__ao_complete_check_progress_reports() argument
1897 assert(ao->progress_reports_outstanding >= 0); in libxl__ao_complete_check_progress_reports()
1899 if (ao_work_outstanding(ao)) in libxl__ao_complete_check_progress_reports()
1902 if (ao->poller) { in libxl__ao_complete_check_progress_reports()
1903 assert(ao->in_initiator); in libxl__ao_complete_check_progress_reports()
1904 if (!ao->constructing) in libxl__ao_complete_check_progress_reports()
1906 libxl__poller_wakeup(egc, ao->poller); in libxl__ao_complete_check_progress_reports()
1907 } else if (ao->how.callback) { in libxl__ao_complete_check_progress_reports()
1908 LOG(DEBUG, "ao %p: complete for callback", ao); in libxl__ao_complete_check_progress_reports()
1909 LIBXL_TAILQ_INSERT_TAIL(&egc->aos_for_callback, ao, entry_for_callback); in libxl__ao_complete_check_progress_reports()
1912 ev = NEW_EVENT(egc, OPERATION_COMPLETE, ao->domid, ao->how.u.for_event); in libxl__ao_complete_check_progress_reports()
1914 ev->u.operation_complete.rc = ao->rc; in libxl__ao_complete_check_progress_reports()
1917 ao->notified = 1; in libxl__ao_complete_check_progress_reports()
1920 ao__check_destroy(ctx, ao); in libxl__ao_complete_check_progress_reports()
1927 libxl__ao *ao; in libxl__ao_create() local
1929 ao = calloc(1, sizeof(*ao)); in libxl__ao_create()
1930 if (!ao) goto out; in libxl__ao_create()
1932 ao->magic = LIBXL__AO_MAGIC; in libxl__ao_create()
1933 ao->constructing = 1; in libxl__ao_create()
1934 ao->in_initiator = 1; in libxl__ao_create()
1935 ao__manip_enter(ao); in libxl__ao_create()
1936 ao->poller = 0; in libxl__ao_create()
1937 ao->domid = domid; in libxl__ao_create()
1938 LIBXL_INIT_GC(ao->gc, ctx); in libxl__ao_create()
1941 ao->how = *how; in libxl__ao_create()
1943 ao->poller = libxl__poller_get(&ao->gc); in libxl__ao_create()
1944 if (!ao->poller) goto out; in libxl__ao_create()
1948 ao, how, ao->how.callback, ao->poller); in libxl__ao_create()
1950 LIBXL_LIST_INSERT_HEAD(&ctx->aos_inprogress, ao, inprogress_entry); in libxl__ao_create()
1952 return ao; in libxl__ao_create()
1955 if (ao) libxl__ao__destroy(ctx, ao); in libxl__ao_create()
1960 int libxl__ao_inprogress(libxl__ao *ao, in libxl__ao_inprogress() argument
1965 uint32_t domid = ao->domid; in libxl__ao_inprogress()
1967 assert(ao->magic == LIBXL__AO_MAGIC); in libxl__ao_inprogress()
1968 assert(ao->constructing); in libxl__ao_inprogress()
1969 assert(ao->in_initiator); in libxl__ao_inprogress()
1970 ao->constructing = 0; in libxl__ao_inprogress()
1972 if (ao->nested_root) in libxl__ao_inprogress()
1973 domid = ao->nested_root->domid; in libxl__ao_inprogress()
1977 ao, ao->poller, in libxl__ao_inprogress()
1978 ao->constructing ? "o" : "", in libxl__ao_inprogress()
1979 ao->in_initiator ? "i" : "", in libxl__ao_inprogress()
1980 ao->complete ? "c" : "", in libxl__ao_inprogress()
1981 ao->notified ? "n" : ""); in libxl__ao_inprogress()
1983 if (ao->poller) { in libxl__ao_inprogress()
1991 assert(ao->magic == LIBXL__AO_MAGIC); in libxl__ao_inprogress()
1993 if (!ao_work_outstanding(ao)) { in libxl__ao_inprogress()
1994 rc = ao->rc; in libxl__ao_inprogress()
1995 ao->notified = 1; in libxl__ao_inprogress()
1999 DBG("ao %p: not ready, waiting",ao); in libxl__ao_inprogress()
2001 rc = eventloop_iteration(&egc,ao->poller); in libxl__ao_inprogress()
2022 ao->in_initiator = 0; in libxl__ao_inprogress()
2023 ao__manip_leave(CTX, ao); in libxl__ao_inprogress()
2060 assert(parent == ao_nested_root(abrt->ao)); in ao__abort()
2066 "ao %p: abrt=%p: aborting", parent, abrt->ao); in ao__abort()
2117 int libxl__ao_aborting(libxl__ao *ao) in libxl__ao_aborting() argument
2119 libxl__ao *root = ao_nested_root(ao); in libxl__ao_aborting()
2121 DBG("ao=%p: aborting at explicit check (root=%p)", ao, root); in libxl__ao_aborting()
2130 libxl__ao *ao = abrt->ao; in libxl__ao_abortable_register() local
2131 libxl__ao *root = ao_nested_root(ao); in libxl__ao_abortable_register()
2136 ao, abrt, root); in libxl__ao_abortable_register()
2140 DBG("ao=%p, abrt=%p: registering (root=%p)", ao, abrt, root); in libxl__ao_abortable_register()
2152 libxl__ao *ao = abrt->ao; in libxl__ao_abortable_deregister() local
2153 libxl__ao *root __attribute__((unused)) = ao_nested_root(ao); in libxl__ao_abortable_deregister()
2156 DBG("ao=%p, abrt=%p: deregistering (root=%p)", ao, abrt, root); in libxl__ao_abortable_deregister()
2178 void libxl__ao_progress_report(libxl__egc *egc, libxl__ao *ao, in libxl__ao_progress_report() argument
2182 assert(!ao->nested_root); in libxl__ao_progress_report()
2184 LOG(DEBUG,"ao %p: progress report: ignored",ao); in libxl__ao_progress_report()
2189 ao->progress_reports_outstanding++; in libxl__ao_progress_report()
2190 aop->ao = ao; in libxl__ao_progress_report()
2194 LOG(DEBUG,"ao %p: progress report: callback queued aop=%p",ao,aop); in libxl__ao_progress_report()
2197 ao, ev, libxl_event_type_to_string(ev->type)); in libxl__ao_progress_report()
2205 static libxl__ao *ao_nested_root(libxl__ao *ao) { in ao_nested_root() argument
2206 libxl__ao *root = ao->nested_root ? : ao; in ao_nested_root()