summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorMichael Brown2007-01-18 04:29:40 +0100
committerMichael Brown2007-01-18 04:29:40 +0100
commit6601a7da6a8cce70348eea1acbcf4296657188b8 (patch)
treed84129cd6e7598f2fee9f288b22115fbc00d4c82 /src/core
parentAdd utility function to parse port from URI (diff)
downloadipxe-6601a7da6a8cce70348eea1acbcf4296657188b8.tar.gz
ipxe-6601a7da6a8cce70348eea1acbcf4296657188b8.tar.xz
ipxe-6601a7da6a8cce70348eea1acbcf4296657188b8.zip
Added async_uninit() to simplify failure paths.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/async.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/core/async.c b/src/core/async.c
index 95bbc057e..26b27f0b3 100644
--- a/src/core/async.c
+++ b/src/core/async.c
@@ -94,6 +94,42 @@ aid_t async_init ( struct async *async, struct async_operations *aop,
}
/**
+ * 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
*
* @v async Asynchronous operation