Changeset 455f190 in mainline


Ignore:
Timestamp:
2011-08-17T13:36:03Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2bc13887
Parents:
26fbb7bb
Message:

Add interfaces for safe accessing foreign client data.

  • Add async_get_client_data_by_hash() to get a reference to some client and pointer to its client data.
  • Add async_put_client_data_by_hash() to drop a reference to some client by its client hash.
Location:
uspace/lib/c
Files:
2 edited

Legend:

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

    r26fbb7bb r455f190  
    201201{
    202202        async_client_data_destroy = dtor;
    203 }
    204 
    205 void *async_get_client_data(void)
    206 {
    207         assert(fibril_connection);
    208         return fibril_connection->client->data;
    209203}
    210204
     
    626620                free(client);
    627621        }
     622}
     623
     624void *async_get_client_data(void)
     625{
     626        assert(fibril_connection);
     627        return fibril_connection->client->data;
     628}
     629
     630void *async_get_client_data_by_hash(sysarg_t client_hash)
     631{
     632        client_t *client = async_client_get(client_hash, false);
     633        if (!client)
     634                return NULL;
     635        if (!client->data) {
     636                async_client_put(client);
     637                return NULL;
     638        }
     639
     640        return client->data;
     641}
     642
     643void async_put_client_data_by_hash(sysarg_t client_hash)
     644{
     645        client_t *client = async_client_get(client_hash, false);
     646
     647        assert(client);
     648        assert(client->data);
     649
     650        async_client_put(client);
    628651}
    629652
  • uspace/lib/c/include/async.h

    r26fbb7bb r455f190  
    186186extern void async_set_client_data_destructor(async_client_data_dtor_t);
    187187extern void *async_get_client_data(void);
     188extern void *async_get_client_data_by_hash(sysarg_t);
     189extern void async_put_client_data_by_hash(sysarg_t);
    188190
    189191extern void async_set_client_connection(async_client_conn_t);
Note: See TracChangeset for help on using the changeset viewer.