Changeset 8080262 in mainline for uspace/lib/c/generic/async/server.c


Ignore:
Timestamp:
2018-07-30T18:55:22Z (6 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2965d18
Parents:
b4c8a7b
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-30 18:07:46)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-30 18:55:22)
Message:

Replace remaining explicit uses of futex_t outside fibril implementation, and get rid of async_futex.

File:
1 edited

Legend:

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

    rb4c8a7b r8080262  
    111111#include <errno.h>
    112112#include <sys/time.h>
    113 #include <libarch/barrier.h>
    114113#include <stdbool.h>
    115114#include <stdlib.h>
     
    125124#define DPRINTF(...)  ((void) 0)
    126125
    127 /** Async framework global futex */
    128 futex_t async_futex = FUTEX_INITIALIZER;
    129 
    130126/** Call data */
    131127typedef struct {
     
    250246static sysarg_t notification_avail = 0;
    251247
    252 /* The remaining structures are guarded by async_futex. */
     248static FIBRIL_RMUTEX_INITIALIZE(conn_mutex);
    253249static hash_table_t conn_hash_table;
    254250
     
    430426         * Remove myself from the connection hash table.
    431427         */
    432         futex_lock(&async_futex);
     428        fibril_rmutex_lock(&conn_mutex);
    433429        hash_table_remove(&conn_hash_table, &(conn_key_t){
    434430                .task_id = fibril_connection->in_task_id,
    435431                .phone_hash = fibril_connection->in_phone_hash
    436432        });
    437         futex_unlock(&async_futex);
     433        fibril_rmutex_unlock(&conn_mutex);
    438434
    439435        /*
     
    517513        /* Add connection to the connection hash table */
    518514
    519         futex_lock(&async_futex);
     515        fibril_rmutex_lock(&conn_mutex);
    520516        hash_table_insert(&conn_hash_table, &conn->link);
    521         futex_unlock(&async_futex);
    522 
    523         fibril_add_ready(conn->fid);
     517        fibril_rmutex_unlock(&conn_mutex);
     518
     519        fibril_start(conn->fid);
    524520
    525521        return conn->fid;
     
    618614        assert(call);
    619615
    620         futex_lock(&async_futex);
     616        fibril_rmutex_lock(&conn_mutex);
    621617
    622618        ht_link_t *link = hash_table_find(&conn_hash_table, &(conn_key_t){
     
    625621        });
    626622        if (!link) {
    627                 futex_unlock(&async_futex);
     623                fibril_rmutex_unlock(&conn_mutex);
    628624                return false;
    629625        }
     
    634630        msg_t *msg = malloc(sizeof(*msg));
    635631        if (!msg) {
    636                 futex_unlock(&async_futex);
     632                fibril_rmutex_unlock(&conn_mutex);
    637633                return false;
    638634        }
     
    644640                conn->close_chandle = call->cap_handle;
    645641
     642        fibril_rmutex_unlock(&conn_mutex);
     643
    646644        /* If the connection fibril is waiting for an event, activate it */
    647645        fibril_notify(&conn->msg_arrived);
    648 
    649         futex_unlock(&async_futex);
    650646        return true;
    651647}
     
    960956        }
    961957
    962         futex_lock(&async_futex);
     958        fibril_rmutex_lock(&conn_mutex);
    963959
    964960        /* If nothing in queue, wait until something arrives */
     
    974970                        memset(call, 0, sizeof(ipc_call_t));
    975971                        IPC_SET_IMETHOD(*call, IPC_M_PHONE_HUNGUP);
    976                         futex_unlock(&async_futex);
     972                        fibril_rmutex_unlock(&conn_mutex);
    977973                        return true;
    978974                }
    979975
    980976                // TODO: replace with cvar
    981                 futex_unlock(&async_futex);
     977                fibril_rmutex_unlock(&conn_mutex);
    982978
    983979                errno_t rc = fibril_wait_timeout(&conn->msg_arrived, expires);
     
    985981                        return false;
    986982
    987                 futex_lock(&async_futex);
     983                fibril_rmutex_lock(&conn_mutex);
    988984        }
    989985
     
    995991        free(msg);
    996992
    997         futex_unlock(&async_futex);
     993        fibril_rmutex_unlock(&conn_mutex);
    998994        return true;
    999995}
Note: See TracChangeset for help on using the changeset viewer.