david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

Added async_uninit() to simplify failure paths.

This commit is contained in:
Michael Brown 2007-01-18 03:29:40 +00:00
parent 5a807994d8
commit 6601a7da6a
2 changed files with 37 additions and 0 deletions

View File

@ -93,6 +93,42 @@ aid_t async_init ( struct async *async, struct async_operations *aop,
return async->aid;
}
/**
* Uninitialise an asynchronous operation
*
* @v async Asynchronous operation
*
* Abandon an asynchronous operation without signalling the parent.
* You may do this only during the period between calling async_init()
* and returning to the parent for the first time. It is designed to
* simplify the error paths of asynchronous operations that themselves
* spawn further asynchronous operations.
*
* An example may help:
*
* int start_something ( ..., struct async *parent ) {
* struct my_data_structure *myself;
*
* ... allocate memory for myself ...
*
* async_init ( &myself->async, &my_async_operations, parent );
* if ( ( rc = start_child_operation ( ..., &myself->async ) ) != 0 ) {
* async_uninit ( &myself->async );
* return rc;
* }
*
* return 0;
* }
*
* It is valid to call async_uninit() on an asynchronous operation
* that has not yet been initialised (i.e. a zeroed-out @c struct @c
* async).
*/
void async_uninit ( struct async *async ) {
if ( async->parent )
list_del ( &async->siblings );
}
/**
* SIGCHLD 'ignore' handler
*

View File

@ -138,6 +138,7 @@ extern struct async_operations orphan_async_operations;
extern aid_t async_init ( struct async *async, struct async_operations *aop,
struct async *parent );
extern void async_uninit ( struct async *async );
extern void async_ignore_signal ( struct async *async, enum signal signal );
extern void async_signal ( struct async *async, enum signal signal );
extern void async_signal_children ( struct async *async, enum signal signal );