Changeset e4f8c77 in mainline for uspace/lib/c/generic/async.c


Ignore:
Timestamp:
2011-07-13T22:39:18Z (13 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e6910c8
Parents:
5974661 (diff), 8ecef91 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libposix.

File:
1 edited

Legend:

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

    r5974661 re4f8c77  
    160160       
    161161        /** Messages that should be delivered to this fibril. */
    162         link_t msg_queue;
     162        list_t msg_queue;
    163163       
    164164        /** Identification of the opening call. */
     
    166166        /** Call data of the opening call. */
    167167        ipc_call_t call;
     168        /** Local argument or NULL if none. */
     169        void *carg;
    168170       
    169171        /** Identification of the closing call. */
     
    171173       
    172174        /** Fibril function that will be used to handle the connection. */
    173         void (*cfibril)(ipc_callid_t, ipc_call_t *);
     175        async_client_conn_t cfibril;
    174176} connection_t;
    175177
     
    213215 * @param callid Hash of the incoming call.
    214216 * @param call   Data of the incoming call.
    215  *
    216  */
    217 static void default_client_connection(ipc_callid_t callid, ipc_call_t *call)
     217 * @param arg    Local argument
     218 *
     219 */
     220static void default_client_connection(ipc_callid_t callid, ipc_call_t *call,
     221    void *arg)
    218222{
    219223        ipc_answer_0(callid, ENOENT);
     
    226230 * @param callid Hash of the incoming call.
    227231 * @param call   Data of the incoming call.
     232 * @param arg    Local argument.
    228233 *
    229234 */
     
    233238
    234239static async_client_conn_t client_connection = default_client_connection;
    235 static async_client_conn_t interrupt_received = default_interrupt_received;
     240static async_interrupt_handler_t interrupt_received = default_interrupt_received;
    236241
    237242/** Setter for client_connection function pointer.
     
    250255 *             notification fibril.
    251256 */
    252 void async_set_interrupt_received(async_client_conn_t intr)
     257void async_set_interrupt_received(async_interrupt_handler_t intr)
    253258{
    254259        interrupt_received = intr;
     
    356361        wd->to_event.inlist = true;
    357362       
    358         link_t *tmp = timeout_list.next;
    359         while (tmp != &timeout_list) {
     363        link_t *tmp = timeout_list.head.next;
     364        while (tmp != &timeout_list.head) {
    360365                awaiter_t *cur
    361366                    = list_get_instance(tmp, awaiter_t, to_event.link);
     
    367372        }
    368373       
    369         list_append(&wd->to_event.link, tmp);
     374        list_insert_before(&wd->to_event.link, tmp);
    370375}
    371376
     
    564569        }
    565570       
    566         msg_t *msg = list_get_instance(conn->msg_queue.next, msg_t, link);
     571        msg_t *msg = list_get_instance(list_first(&conn->msg_queue), msg_t, link);
    567572        list_remove(&msg->link);
    568573       
     
    633638         */
    634639        fibril_connection->cfibril(fibril_connection->callid,
    635             &fibril_connection->call);
     640            &fibril_connection->call, fibril_connection->carg);
    636641       
    637642        /*
     
    670675        while (!list_empty(&fibril_connection->msg_queue)) {
    671676                msg_t *msg =
    672                     list_get_instance(fibril_connection->msg_queue.next, msg_t,
    673                     link);
     677                    list_get_instance(list_first(&fibril_connection->msg_queue),
     678                    msg_t, link);
    674679               
    675680                list_remove(&msg->link);
     
    704709 * @param cfibril       Fibril function that should be called upon opening the
    705710 *                      connection.
     711 * @param carg          Extra argument to pass to the connection fibril
    706712 *
    707713 * @return New fibril id or NULL on failure.
     
    710716fid_t async_new_connection(sysarg_t in_task_hash, sysarg_t in_phone_hash,
    711717    ipc_callid_t callid, ipc_call_t *call,
    712     async_client_conn_t cfibril)
     718    async_client_conn_t cfibril, void *carg)
    713719{
    714720        connection_t *conn = malloc(sizeof(*conn));
     
    725731        conn->callid = callid;
    726732        conn->close_callid = 0;
     733        conn->carg = carg;
    727734       
    728735        if (call)
     
    779786                /* Open new connection with fibril, etc. */
    780787                async_new_connection(call->in_task_hash, IPC_GET_ARG5(*call),
    781                     callid, call, client_connection);
     788                    callid, call, client_connection, NULL);
    782789                return;
    783790        }
     
    799806        futex_down(&async_futex);
    800807       
    801         link_t *cur = timeout_list.next;
    802         while (cur != &timeout_list) {
     808        link_t *cur = list_first(&timeout_list);
     809        while (cur != NULL) {
    803810                awaiter_t *waiter =
    804811                    list_get_instance(cur, awaiter_t, to_event.link);
     
    806813                if (tv_gt(&waiter->to_event.expires, &tv))
    807814                        break;
    808                
    809                 cur = cur->next;
    810815               
    811816                list_remove(&waiter->to_event.link);
     
    821826                        fibril_add_ready(waiter->fid);
    822827                }
     828               
     829                cur = list_first(&timeout_list);
    823830        }
    824831       
     
    847854                suseconds_t timeout;
    848855                if (!list_empty(&timeout_list)) {
    849                         awaiter_t *waiter = list_get_instance(timeout_list.next,
    850                             awaiter_t, to_event.link);
     856                        awaiter_t *waiter = list_get_instance(
     857                            list_first(&timeout_list), awaiter_t, to_event.link);
    851858                       
    852859                        struct timeval tv;
     
    14141421 */
    14151422int async_connect_to_me(async_exch_t *exch, sysarg_t arg1, sysarg_t arg2,
    1416     sysarg_t arg3, async_client_conn_t client_receiver)
     1423    sysarg_t arg3, async_client_conn_t client_receiver, void *carg)
    14171424{
    14181425        if (exch == NULL)
     
    14281435        if (client_receiver != NULL)
    14291436                async_new_connection(task_hash, phone_hash, 0, NULL,
    1430                     client_receiver);
     1437                    client_receiver, carg);
    14311438       
    14321439        return EOK;
     
    17241731                 */
    17251732                exch = (async_exch_t *)
    1726                     list_get_instance(sess->exch_list.next, async_exch_t, sess_link);
     1733                    list_get_instance(list_first(&sess->exch_list),
     1734                    async_exch_t, sess_link);
     1735               
    17271736                list_remove(&exch->sess_link);
    17281737                list_remove(&exch->global_link);
     
    17361745                        exch = (async_exch_t *) malloc(sizeof(async_exch_t));
    17371746                        if (exch != NULL) {
    1738                                 list_initialize(&exch->sess_link);
    1739                                 list_initialize(&exch->global_link);
     1747                                link_initialize(&exch->sess_link);
     1748                                link_initialize(&exch->global_link);
    17401749                                exch->sess = sess;
    17411750                                exch->phone = sess->phone;
     
    17541763                                exch = (async_exch_t *) malloc(sizeof(async_exch_t));
    17551764                                if (exch != NULL) {
    1756                                         list_initialize(&exch->sess_link);
    1757                                         list_initialize(&exch->global_link);
     1765                                        link_initialize(&exch->sess_link);
     1766                                        link_initialize(&exch->global_link);
    17581767                                        exch->sess = sess;
    17591768                                        exch->phone = phone;
     
    17671776                                 */
    17681777                                exch = (async_exch_t *)
    1769                                     list_get_instance(inactive_exch_list.next, async_exch_t,
    1770                                     global_link);
     1778                                    list_get_instance(list_first(&inactive_exch_list),
     1779                                    async_exch_t, global_link);
     1780                               
    17711781                                list_remove(&exch->sess_link);
    17721782                                list_remove(&exch->global_link);
     
    18081818        async_sess_t *sess = exch->sess;
    18091819       
     1820        atomic_dec(&sess->refcnt);
     1821       
    18101822        if (sess->mgmt == EXCHANGE_SERIALIZE)
    18111823                fibril_mutex_unlock(&sess->mutex);
Note: See TracChangeset for help on using the changeset viewer.