diff options
Diffstat (limited to 'libports/ports.h')
-rw-r--r-- | libports/ports.h | 87 |
1 files changed, 59 insertions, 28 deletions
diff --git a/libports/ports.h b/libports/ports.h index 2d52daa4..9a5ccbc2 100644 --- a/libports/ports.h +++ b/libports/ports.h @@ -1,5 +1,5 @@ /* Ports library for server construction - Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1993,94,95,96,97,99,2000 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -24,6 +24,7 @@ #include <mach.h> #include <stdlib.h> #include <hurd.h> +#include <hurd/ihash.h> #include <mach/notify.h> /* These are global values for common flags used in the various structures. @@ -45,7 +46,7 @@ struct port_info mach_port_t port_right; struct rpc_info *current_rpcs; struct port_bucket *bucket; - void **hentry; + hurd_ihash_locp_t hentry; struct port_info *next, **prevp; /* links on port_class list */ }; /* FLAGS above are the following: */ @@ -57,7 +58,7 @@ struct port_info struct port_bucket { mach_port_t portset; - struct ihash *htable; + struct hurd_ihash htable; int rpcs; int flags; int count; @@ -92,6 +93,7 @@ struct rpc_info thread_t thread; struct rpc_info *next, **prevp; struct rpc_notify *notifies; + struct rpc_info *interrupted_next; }; /* An rpc has requested interruption on a port notification. */ @@ -162,7 +164,19 @@ error_t ports_create_port (struct port_class *class, struct port_bucket *bucket, size_t size, void *result); - + +/* Just like ports_create_port, except don't actually put the port + into the portset underlying BUCKET. This is intended to be used + for cases where the port right must be given out before the port is + fully initialized; with this call you are guaranteed that no RPC + service will occur on the port until you have finished initializing + it and installed it into the portset yourself. */ +error_t +ports_create_port_noinstall (struct port_class *class, + struct port_bucket *bucket, + size_t size, + void *result); + /* For an existing RECEIVE right, create and return in RESULT a new port structure; BUCKET, SIZE, and CLASS args are as for ports_create_port. */ error_t ports_import_port (struct port_class *class, @@ -180,12 +194,12 @@ void ports_reallocate_from_external (void *port, mach_port_t receive); /* Destroy the receive right currently associated with PORT. After this call, ports_reallocate_port and ports_reallocate_from_external - may not be used. */ -void ports_destroy_right (void *port); + may not be used. Always returns 0, for convenient use as an iterator. */ +error_t ports_destroy_right (void *port); /* Return the receive right currently associated with PORT. The effects on PORT are the same as in ports_destroy_right, except that the receive - right itself is not affected. Note that in multi-threaded servers, + right itself is not affected. Note that in multi-threaded servers, messages might already have been dequeued for this port before it gets removed from the portset; such messages will get EOPNOTSUPP errors. */ mach_port_t ports_claim_right (void *port); @@ -196,20 +210,25 @@ mach_port_t ports_claim_right (void *port); were called. */ error_t ports_transfer_right (void *topt, void *frompt); -/* Return the name of the receive right associated with PORT. The user - is responsible for creating an ordinary send right from this name. */ +/* Return the name of the receive right associated with PORT. This assumes + that send rights will shortly be created, and arranges for notifications + accordingly. The user is responsible for creating an ordinary send + right from this name. */ mach_port_t ports_get_right (void *port); +/* This convenience function uses ports_get_right, and + deals with the creation of a send right as well. */ +mach_port_t ports_get_send_right (void *port); /* Reference counting */ - + /* Look up PORT and return the associated port structure, allocating a reference. If the call fails, return 0. If BUCKET is nonzero, then it specifies a bucket to search; otherwise all buckets will be searched. If CLASS is nonzero, then the lookup will fail if PORT is not in CLASS. */ -void *ports_lookup_port (struct port_bucket *bucket, +void *ports_lookup_port (struct port_bucket *bucket, mach_port_t port, struct port_class *class); /* Allocate another reference to PORT. */ @@ -238,7 +257,7 @@ int ports_count_class (struct port_class *class); of ports currently in BUCKET. */ int ports_count_bucket (struct port_bucket *bucket); -/* Permit suspended port creation (blocked by ports_count_class) +/* Permit suspended port creation (blocked by ports_count_class) to continue. */ void ports_enable_class (struct port_class *class); @@ -250,16 +269,23 @@ void ports_enable_bucket (struct port_bucket *bucket); error_t ports_bucket_iterate (struct port_bucket *bucket, error_t (*fun)(void *port)); +/* Call FUN once for each port in CLASS. */ +error_t ports_class_iterate (struct port_class *class, + error_t (*fun)(void *port)); +/* Internal entrypoint for above two. */ +error_t _ports_bucket_class_iterate (struct port_bucket *bucket, + struct port_class *class, + error_t (*fun)(void *port)); /* RPC management */ - + /* Type of MiG demuxer routines. */ -typedef int (*ports_demuxer_type)(mach_msg_header_t *inp, +typedef int (*ports_demuxer_type)(mach_msg_header_t *inp, mach_msg_header_t *outp); -/* Call this when an RPC is beginning on PORT. INFO should be - allocated by the caller and will be used to hold dynamic state. +/* Call this when an RPC is beginning on PORT. INFO should be + allocated by the caller and will be used to hold dynamic state. If this RPC should be abandoned, return EDIED; otherwise we return zero. */ error_t ports_begin_rpc (void *port, mach_msg_id_t msg_id, @@ -281,21 +307,17 @@ void ports_manage_port_operations_one_thread(struct port_bucket *bucket, for each incoming message. Return if GLOBAL_TIMEOUT is nonzero and no messages have been receieved for GLOBAL_TIMEOUT milliseconds. Create threads as necessary to handle incoming messages so that no - port is starved because of sluggishness on another port. All - threads created (and the calling thread) will be wired with - cthread_wire if WIRE_CTHREADS is non-zero. All threads created - (and the calling thread) will be wired with thread_wire if - WIRE_THREADS is non-zero (it must be the priviliged host port in - order to succeed). If LOCAL_TIMEOUT is non-zero, then individual - threads will die off if they handle no incoming messages for - LOCAL_TIMEOUT milliseconds. */ + port is starved because of sluggishness on another port. If + LOCAL_TIMEOUT is non-zero, then individual threads will die off if + they handle no incoming messages for LOCAL_TIMEOUT milliseconds. + HOOK (if not null) will be called in each new thread immediately + after it is created. */ void ports_manage_port_operations_multithread (struct port_bucket *bucket, ports_demuxer_type demuxer, int thread_timeout, int global_timeout, - int wire_cthreads, - mach_port_t wire_threads); - + void (*hook)(void)); + /* Interrupt any pending RPC on PORT. Wait for all pending RPC's to finish, and then block any new RPC's starting on that port. */ error_t ports_inhibit_port_rpcs (void *port); @@ -325,6 +347,13 @@ void ports_resume_all_rpcs (void); /* Cancel (with thread_cancel) any RPC's in progress on PORT. */ void ports_interrupt_rpcs (void *port); +/* If the current thread's rpc has been interrupted with + ports_interrupt_rpcs, return true (and clear the interrupted flag). */ +int ports_self_interrupted (); + +/* Add RPC to the list of rpcs that have been interrupted. */ +void _ports_record_interruption (struct rpc_info *rpc); + /* Arrange for hurd_cancel to be called on RPC's thread if OBJECT gets notified that any of the things in COND have happened to PORT. RPC should be an rpc on OBJECT. */ @@ -363,7 +392,7 @@ extern kern_return_t /* A default interrupt server */ int ports_interrupt_server (mach_msg_header_t *, mach_msg_header_t *); -extern kern_return_t ports_S_interrupt_operation (mach_port_t, +extern kern_return_t ports_S_interrupt_operation (mach_port_t, mach_port_seqno_t); /* Private data */ @@ -376,5 +405,7 @@ extern int _ports_flags; #define _PORTS_BLOCKED PORTS_BLOCKED #define _PORTS_INHIBIT_WAIT PORTS_INHIBIT_WAIT void _ports_complete_deallocate (struct port_info *); +error_t _ports_create_port_internal (struct port_class *, struct port_bucket *, + size_t, void *, int); #endif |