diff options
author | Roland McGrath <roland@gnu.org> | 2001-11-10 00:11:33 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2001-11-10 00:11:33 +0000 |
commit | 377f22d8ece0078445bfe664ac8b399b55883bc6 (patch) | |
tree | 1bf36c3fa370e437ee445c27a6b51bd9b8f0a33c /hurd | |
parent | 7fd52cc83c9750963beb51a46e445e67ef5027a9 (diff) | |
download | glibc-377f22d8ece0078445bfe664ac8b399b55883bc6.tar.gz |
2001-11-09 Roland McGrath <roland@frob.com>
* hurd/privports.c (__get_privileged_ports):
Only contact the proc server if necessary for this call.
Suggested by Neal H Walfield <neal@cs.uml.edu>.
Check error return for mach_port_mod_refs.
Diffstat (limited to 'hurd')
-rw-r--r-- | hurd/privports.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/hurd/privports.c b/hurd/privports.c index 018b2ddee1..5d3232b214 100644 --- a/hurd/privports.c +++ b/hurd/privports.c @@ -28,7 +28,8 @@ kern_return_t __get_privileged_ports (host_priv_t *host_priv_ptr, device_t *device_master_ptr) { - if (! _hurd_host_priv) + if ((host_priv_ptr && _hurd_host_priv == MACH_PORT_NULL) + || (device_master_ptr && _hurd_device_master == MACH_PORT_NULL)) { error_t err; @@ -47,16 +48,24 @@ __get_privileged_ports (host_priv_t *host_priv_ptr, if (host_priv_ptr) { - __mach_port_mod_refs (mach_task_self (), - _hurd_host_priv, MACH_PORT_RIGHT_SEND, 1); + error_t err = _hurd_host_priv == MACH_PORT_NULL ? 0 + : __mach_port_mod_refs (mach_task_self (), + _hurd_host_priv, MACH_PORT_RIGHT_SEND, +1); + if (err) + return err; *host_priv_ptr = _hurd_host_priv; } + if (device_master_ptr) { - __mach_port_mod_refs (mach_task_self (), - _hurd_device_master, MACH_PORT_RIGHT_SEND, 1); + error_t err = _hurd_device_master == MACH_PORT_NULL ? 0 + : __mach_port_mod_refs (mach_task_self (), + _hurd_device_master, MACH_PORT_RIGHT_SEND, +1); + if (err) + return err; *device_master_ptr = _hurd_device_master; } + return KERN_SUCCESS; } weak_alias (__get_privileged_ports, get_privileged_ports) |