Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/async.c

    r4d6629f r503ffce  
    106106#include <fibril.h>
    107107#include <adt/hash_table.h>
     108#include <adt/hash.h>
    108109#include <adt/list.h>
    109110#include <assert.h>
     
    587588};
    588589
    589 /** Compute hash into the connection hash table based on the source phone hash.
    590  *
    591  * @param key Pointer to source phone hash.
     590typedef struct {
     591        task_id_t task_id;
     592        sysarg_t phone_hash;
     593} conn_key_t;
     594
     595/** Compute hash into the connection hash table
     596 *
     597 * The hash is based on the source task ID and the source phone hash. The task
     598 * ID is included in the hash because a phone hash alone might not be unique
     599 * while we still track connections for killed tasks due to kernel's recycling
     600 * of phone structures.
     601 *
     602 * @param key Pointer to the connection key structure.
    592603 *
    593604 * @return Index into the connection hash table.
     
    596607static size_t conn_key_hash(void *key)
    597608{
    598         sysarg_t in_phone_hash = *(sysarg_t *) key;
    599         return in_phone_hash;
     609        conn_key_t *ck = (conn_key_t *) key;
     610
     611        size_t hash = 0;
     612        hash = hash_combine(hash, LOWER32(ck->task_id));
     613        hash = hash_combine(hash, UPPER32(ck->task_id));
     614        hash = hash_combine(hash, ck->phone_hash);
     615        return hash;
    600616}
    601617
     
    603619{
    604620        connection_t *conn = hash_table_get_inst(item, connection_t, link);
    605         return conn_key_hash(&conn->in_phone_hash);
     621        return conn_key_hash(&(conn_key_t){
     622                .task_id = conn->in_task_id,
     623                .phone_hash = conn->in_phone_hash
     624        });
    606625}
    607626
    608627static bool conn_key_equal(void *key, const ht_link_t *item)
    609628{
    610         sysarg_t in_phone_hash = *(sysarg_t *) key;
     629        conn_key_t *ck = (conn_key_t *) key;
    611630        connection_t *conn = hash_table_get_inst(item, connection_t, link);
    612         return (in_phone_hash == conn->in_phone_hash);
     631        return ((ck->task_id == conn->in_task_id) &&
     632            (ck->phone_hash == conn->in_phone_hash));
    613633}
    614634
     
    716736         */
    717737        futex_down(&async_futex);
    718         hash_table_remove(&conn_hash_table, &fibril_connection->in_phone_hash);
     738        hash_table_remove(&conn_hash_table, &(conn_key_t){
     739                .task_id = fibril_connection->in_task_id,
     740                .phone_hash = fibril_connection->in_phone_hash
     741        });
    719742        futex_up(&async_futex);
    720743       
     
    951974        futex_down(&async_futex);
    952975       
    953         ht_link_t *link = hash_table_find(&conn_hash_table, &call->in_phone_hash);
     976        ht_link_t *link = hash_table_find(&conn_hash_table, &(conn_key_t){
     977                .task_id = call->in_task_id,
     978                .phone_hash = call->in_phone_hash
     979        });
    954980        if (!link) {
    955981                futex_up(&async_futex);
     
    13151341       
    13161342        /* Kernel notification */
    1317         if ((callid & IPC_CALLID_NOTIFICATION)) {
     1343        if (call->flags & IPC_CALLID_NOTIFICATION) {
    13181344                fibril_t *fibril = (fibril_t *) __tcb_get()->fibril_data;
    13191345                unsigned oldsw = fibril->switches;
     
    14691495                }
    14701496               
    1471                 if (callid & IPC_CALLID_ANSWERED)
     1497                if (call.flags & IPC_CALLID_ANSWERED)
    14721498                        continue;
    14731499               
Note: See TracChangeset for help on using the changeset viewer.