Changeset f5837524 in mainline for uspace/srv/ns/task.c


Ignore:
Timestamp:
2018-10-29T17:15:02Z (5 years ago)
Author:
Jakub Jermar <jakub@…>
Children:
eec201d
Parents:
184f2f8a
git-author:
Jakub Jermar <jakub@…> (2018-10-28 12:42:35)
git-committer:
Jakub Jermar <jakub@…> (2018-10-29 17:15:02)
Message:

Use user-defined labels instead of phone hashes

This commit changes the way how the async framework maps incomming calls
to connections. Instead of abusing the kernel addresses of attached
phones as identifiers, the IPC_M_CONNECT_TO_ME and IPC_M_CONNECT_ME_TO
messages allow the server to specify an arbitrary label which is
remembered in the connected phone and consequently imprinted on each
call which is routed through this phone.

The async framework uses the address of the connection structure as the
label. This removes the need for a connection hash table because each
incoming call already remembers the connection in its label.

To disambiguate this new label and the other user-defined label used for
answers, the call structure now has the request_label member for the
former and answer_label member for the latter.

This commit also moves the kernel definition of ipc_data_t to abi/ and
removes the uspace redefinition thereof. Finally, when forwarding the
IPC_M_CONNECT_TO_ME call, the phone capability and the kernel object
allocated in request_process are now correctly disposed of.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/ns/task.c

    r184f2f8a rf5837524  
    9191typedef struct {
    9292        ht_link_t link;
    93         sysarg_t in_phone_hash;  /**< Incoming phone hash. */
    94         task_id_t id;            /**< Task ID. */
     93        sysarg_t label;  /**< Incoming phone label. */
     94        task_id_t id;    /**< Task ID. */
    9595} p2i_entry_t;
    9696
    97 /* phone-to-id hash table operations */
     97/* label-to-id hash table operations */
    9898
    9999static size_t p2i_key_hash(void *key)
    100100{
    101         sysarg_t in_phone_hash = *(sysarg_t *)key;
    102         return in_phone_hash;
     101        sysarg_t label = *(sysarg_t *)key;
     102        return label;
    103103}
    104104
     
    106106{
    107107        p2i_entry_t *entry = hash_table_get_inst(item, p2i_entry_t, link);
    108         return entry->in_phone_hash;
     108        return entry->label;
    109109}
    110110
    111111static bool p2i_key_equal(void *key, const ht_link_t *item)
    112112{
    113         sysarg_t in_phone_hash = *(sysarg_t *)key;
     113        sysarg_t label = *(sysarg_t *)key;
    114114        p2i_entry_t *entry = hash_table_get_inst(item, p2i_entry_t, link);
    115115
    116         return (in_phone_hash == entry->in_phone_hash);
     116        return (label == entry->label);
    117117}
    118118
     
    137137};
    138138
    139 /** Map phone hash to task ID */
     139/** Map phone label to task ID */
    140140static hash_table_t phone_to_id;
    141141
     
    227227        task_id_t id = MERGE_LOUP32(IPC_GET_ARG1(*call), IPC_GET_ARG2(*call));
    228228
    229         ht_link_t *link = hash_table_find(&phone_to_id, &call->in_phone_hash);
     229        ht_link_t *link = hash_table_find(&phone_to_id, &call->request_label);
    230230        if (link != NULL)
    231231                return EEXIST;
     
    245245         */
    246246
    247         entry->in_phone_hash = call->in_phone_hash;
     247        assert(call->request_label);
     248        entry->label = call->request_label;
    248249        entry->id = id;
    249250        hash_table_insert(&phone_to_id, &entry->link);
     
    262263}
    263264
    264 static errno_t get_id_by_phone(sysarg_t phone_hash, task_id_t *id)
    265 {
    266         ht_link_t *link = hash_table_find(&phone_to_id, &phone_hash);
     265static errno_t get_id_by_phone(sysarg_t label, task_id_t *id)
     266{
     267        assert(label);
     268        ht_link_t *link = hash_table_find(&phone_to_id, &label);
    267269        if (link == NULL)
    268270                return ENOENT;
     
    276278errno_t ns_task_retval(ipc_call_t *call)
    277279{
    278         task_id_t id = call->in_task_id;
     280        task_id_t id = call->task_id;
    279281
    280282        ht_link_t *link = hash_table_find(&task_hash_table, &id);
     
    297299{
    298300        task_id_t id;
    299         errno_t rc = get_id_by_phone(call->in_phone_hash, &id);
     301        errno_t rc = get_id_by_phone(call->request_label, &id);
    300302        if (rc != EOK)
    301303                return rc;
    302304
    303305        /* Delete from phone-to-id map. */
    304         hash_table_remove(&phone_to_id, &call->in_phone_hash);
     306        hash_table_remove(&phone_to_id, &call->request_label);
    305307
    306308        /* Mark task as finished. */
Note: See TracChangeset for help on using the changeset viewer.