Changeset f5837524 in mainline for uspace/srv


Ignore:
Timestamp:
2018-10-29T17:15:02Z (7 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.

Location:
uspace/srv
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/audio/hound/audio_device.c

    r184f2f8a rf5837524  
    269269
    270270        /* Answer initial request */
    271         async_answer_0(icall, EOK);
     271        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    272272        audio_device_t *dev = arg;
    273273        assert(dev);
  • uspace/srv/bd/vbd/vbd.c

    r184f2f8a rf5837524  
    365365
    366366        /* Accept the connection */
    367         async_answer_0(icall, EOK);
     367        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    368368
    369369        while (true) {
  • uspace/srv/clipboard/clipboard.c

    r184f2f8a rf5837524  
    155155{
    156156        /* Accept connection */
    157         async_answer_0(icall, EOK);
     157        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    158158
    159159        while (true) {
  • uspace/srv/devman/client_conn.c

    r184f2f8a rf5837524  
    748748{
    749749        /* Accept connection. */
    750         async_answer_0(icall, EOK);
     750        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    751751
    752752        while (true) {
  • uspace/srv/devman/drv_conn.c

    r184f2f8a rf5837524  
    588588
    589589        /* Accept the connection. */
    590         async_answer_0(icall, EOK);
     590        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    591591
    592592        client = async_get_client_data();
  • uspace/srv/hid/compositor/compositor.c

    r184f2f8a rf5837524  
    918918        /* Allocate resources for new window and register it to the location service. */
    919919        if (service_id == winreg_id) {
    920                 async_answer_0(icall, EOK);
     920                async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    921921
    922922                async_get_call(&call);
     
    997997
    998998        if (win) {
    999                 async_answer_0(icall, EOK);
     999                async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    10001000        } else {
    10011001                async_answer_0(icall, EINVAL);
  • uspace/srv/hid/input/input.c

    r184f2f8a rf5837524  
    328328        }
    329329
    330         async_answer_0(icall, EOK);
     330        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    331331
    332332        while (true) {
  • uspace/srv/hid/isdv4_tablet/main.c

    r184f2f8a rf5837524  
    6565static void mouse_connection(ipc_call_t *icall, void *arg)
    6666{
    67         async_answer_0(icall, EOK);
     67        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    6868
    6969        async_sess_t *sess =
  • uspace/srv/hid/output/output.c

    r184f2f8a rf5837524  
    398398{
    399399        /* Accept the connection */
    400         async_answer_0(icall, EOK);
     400        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    401401
    402402        while (true) {
  • uspace/srv/hid/s3c24xx_ts/s3c24xx_ts.c

    r184f2f8a rf5837524  
    372372static void s3c24xx_ts_connection(ipc_call_t *icall, void *arg)
    373373{
    374         async_answer_0(icall, EOK);
     374        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    375375
    376376        while (true) {
  • uspace/srv/loader/main.c

    r184f2f8a rf5837524  
    366366
    367367        /* Accept the connection */
    368         async_answer_0(icall, EOK);
     368        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    369369
    370370        /* Ignore parameters, the connection is already open */
  • uspace/srv/locsrv/locsrv.c

    r184f2f8a rf5837524  
    13961396{
    13971397        /* Accept connection */
    1398         async_answer_0(icall, EOK);
     1398        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    13991399
    14001400        /*
     
    14631463{
    14641464        /* Accept connection */
    1465         async_answer_0(icall, EOK);
     1465        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    14661466
    14671467        while (true) {
  • uspace/srv/logger/ctl.c

    r184f2f8a rf5837524  
    6868        int fd;
    6969
    70         async_answer_0(icall, EOK);
     70        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    7171        logger_log("control: new client.\n");
    7272
  • uspace/srv/logger/writer.c

    r184f2f8a rf5837524  
    9898
    9999        /* Acknowledge the connection. */
    100         async_answer_0(icall, EOK);
     100        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    101101
    102102        logger_log("writer: new client.\n");
  • uspace/srv/net/dhcp/main.c

    r184f2f8a rf5837524  
    128128
    129129        /* Accept the connection */
    130         async_answer_0(icall, EOK);
     130        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    131131
    132132        while (true) {
  • uspace/srv/net/dnsrsrv/dnsrsrv.c

    r184f2f8a rf5837524  
    213213
    214214        /* Accept the connection */
    215         async_answer_0(icall, EOK);
     215        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    216216
    217217        while (true) {
  • uspace/srv/net/inetsrv/inetcfg.c

    r184f2f8a rf5837524  
    742742
    743743        /* Accept the connection */
    744         async_answer_0(icall, EOK);
     744        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    745745
    746746        while (true) {
  • uspace/srv/net/inetsrv/inetping.c

    r184f2f8a rf5837524  
    284284
    285285        /* Accept the connection */
    286         async_answer_0(icall, EOK);
     286        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    287287
    288288        inetping_client_t client;
  • uspace/srv/net/inetsrv/inetsrv.c

    r184f2f8a rf5837524  
    390390
    391391        /* Accept the connection */
    392         async_answer_0(icall, EOK);
     392        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    393393
    394394        inet_client_init(&client);
  • uspace/srv/net/tcp/service.c

    r184f2f8a rf5837524  
    11691169
    11701170        /* Accept the connection */
    1171         async_answer_0(icall, EOK);
     1171        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    11721172
    11731173        log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_client_conn() - client=%p",
  • uspace/srv/net/udp/service.c

    r184f2f8a rf5837524  
    667667
    668668        /* Accept the connection */
    669         async_answer_0(icall, EOK);
     669        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    670670
    671671        log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_client_conn()");
  • uspace/srv/ns/ns.c

    r184f2f8a rf5837524  
    7070        }
    7171
    72         async_answer_0(icall, EOK);
     72        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    7373
    7474        while (true) {
  • 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. */
  • uspace/srv/taskmon/taskmon.c

    r184f2f8a rf5837524  
    108108{
    109109        /* Accept the connection */
    110         async_answer_0(icall, EOK);
     110        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    111111
    112112        while (true) {
  • uspace/srv/vfs/vfs.c

    r184f2f8a rf5837524  
    5656static void vfs_pager(ipc_call_t *icall, void *arg)
    5757{
    58         async_answer_0(icall, EOK);
     58        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    5959
    6060        while (true) {
     
    8383                vfs_op_pass_handle(
    8484                    (task_id_t) MERGE_LOUP32(IPC_GET_ARG4(*call),
    85                     IPC_GET_ARG5(*call)), call->in_task_id,
     85                    IPC_GET_ARG5(*call)), call->task_id,
    8686                    (int) IPC_GET_ARG2(*call));
    8787}
  • uspace/srv/vfs/vfs_ipc.c

    r184f2f8a rf5837524  
    324324         * This call needs to be answered.
    325325         */
    326         async_answer_0(icall, EOK);
     326        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    327327
    328328        while (cont) {
  • uspace/srv/volsrv/volsrv.c

    r184f2f8a rf5837524  
    551551
    552552        /* Accept the connection */
    553         async_answer_0(icall, EOK);
     553        async_answer_5(icall, EOK, 0, 0, 0, 0, async_get_label());
    554554
    555555        while (true) {
Note: See TracChangeset for help on using the changeset viewer.