mirror of
https://github.com/ipxe/ipxe
synced 2025-12-18 10:30:23 +03:00
Create and use async_block() macro; it cuts down on the visual overhead
of blocking on asynchronous operations, when that isn't an important aspect of the code.
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include <byteswap.h>
|
||||
#include <vsprintf.h>
|
||||
#include <gpxe/in.h>
|
||||
#include <gpxe/ip.h>
|
||||
#include <gpxe/dhcp.h>
|
||||
#include <gpxe/async.h>
|
||||
#include <gpxe/netdevice.h>
|
||||
@@ -65,13 +66,8 @@ int dhcp ( struct net_device *netdev ) {
|
||||
printf ( "DHCP (%s %s)...", netdev->name, netdev_hwaddr ( netdev ) );
|
||||
memset ( &dhcp, 0, sizeof ( dhcp ) );
|
||||
dhcp.netdev = netdev;
|
||||
async_init_orphan ( &async );
|
||||
if ( ( rc = start_dhcp ( &dhcp, &async ) ) != 0 ) {
|
||||
printf ( "could not start (%s)\n", strerror ( rc ) );
|
||||
return rc;
|
||||
}
|
||||
async_wait ( &async, &rc, 1 );
|
||||
if ( rc != 0 ) {
|
||||
if ( ( rc = async_block ( &async,
|
||||
start_dhcp ( &dhcp, &async ) ) ) != 0 ) {
|
||||
printf ( "failed (%s)\n", strerror ( rc ) );
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -86,11 +86,8 @@ int fetch ( const char *uri_string, userptr_t *data, size_t *len ) {
|
||||
}
|
||||
}
|
||||
|
||||
async_init_orphan ( &async );
|
||||
if ( ( rc = download ( uri, &buffer, &async ) ) != 0 )
|
||||
goto err;
|
||||
async_wait ( &async, &rc, 1 );
|
||||
if ( rc != 0 )
|
||||
if ( ( rc = async_block ( &async,
|
||||
download ( uri, &buffer, &async ) ) ) != 0 )
|
||||
goto err;
|
||||
|
||||
/* Fill in buffer address and length */
|
||||
|
||||
Reference in New Issue
Block a user