From ff8528ea9a69ca2ef6cfbed0b7a1283e165aabe6 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Tue, 16 Jan 2007 08:10:54 +0000 Subject: 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. --- src/usr/dhcpmgmt.c | 10 +++------- src/usr/fetch.c | 7 ++----- 2 files changed, 5 insertions(+), 12 deletions(-) (limited to 'src/usr') diff --git a/src/usr/dhcpmgmt.c b/src/usr/dhcpmgmt.c index 90ed62bf4..6f0302741 100644 --- a/src/usr/dhcpmgmt.c +++ b/src/usr/dhcpmgmt.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -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; } diff --git a/src/usr/fetch.c b/src/usr/fetch.c index 45031049c..11197e9fd 100644 --- a/src/usr/fetch.c +++ b/src/usr/fetch.c @@ -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 */ -- cgit v1.2.3-55-g7522