Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 77cea41 in mainline


Ignore:
Timestamp:
2010-12-24T17:00:35Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
700af62
Parents:
1522b42 (diff), ab49a0d (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 development/ changes

Files:
4 deleted
22 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/ddi/irq.h

    r1522b42 r77cea41  
    189189extern hash_table_t irq_uspace_hash_table;
    190190
     191extern inr_t last_inr;
     192
    191193extern void irq_init(size_t, size_t);
    192194extern void irq_initialize(irq_t *);
  • kernel/generic/src/ddi/irq.c

    r1522b42 r77cea41  
    136136static size_t buckets;
    137137
     138/** Last valid INR. */
     139inr_t last_inr = 0;
     140
    138141/** Initialize IRQ subsystem.
    139142 *
     
    145148{
    146149        buckets = chains;
     150        last_inr = inrs - 1;
     151
    147152        /*
    148153         * Be smart about the choice of the hash table operations.
  • kernel/generic/src/ipc/irq.c

    r1522b42 r77cea41  
    131131/** Register an answerbox as a receiving end for IRQ notifications.
    132132 *
    133  * @param box     Receiving answerbox.
    134  * @param inr     IRQ number.
    135  * @param devno   Device number.
    136  * @param imethod Interface and method to be associated
    137  *                with the notification.
    138  * @param ucode   Uspace pointer to top-half pseudocode.
    139  *
    140  * @return EBADMEM, ENOENT or EEXISTS on failure or 0 on success.
     133 * @param box           Receiving answerbox.
     134 * @param inr           IRQ number.
     135 * @param devno         Device number.
     136 * @param imethod       Interface and method to be associated with the
     137 *                      notification.
     138 * @param ucode         Uspace pointer to top-half pseudocode.
     139 * @return              EOK on success or a negative error code.
    141140 *
    142141 */
     
    148147                (sysarg_t) devno
    149148        };
     149
     150        if ((inr < 0) || (inr > last_inr))
     151                return ELIMIT;
    150152       
    151153        irq_code_t *code;
     
    208210/** Unregister task from IRQ notification.
    209211 *
    210  * @param box   Answerbox associated with the notification.
    211  * @param inr   IRQ number.
    212  * @param devno Device number.
    213  *
     212 * @param box           Answerbox associated with the notification.
     213 * @param inr           IRQ number.
     214 * @param devno         Device number.
     215 * @return              EOK on success or a negative error code.
    214216 */
    215217int ipc_irq_unregister(answerbox_t *box, inr_t inr, devno_t devno)
     
    219221                (sysarg_t) devno
    220222        };
     223
     224        if ((inr < 0) || (inr > last_inr))
     225                return ELIMIT;
    221226       
    222227        irq_spinlock_lock(&irq_uspace_hash_table_lock, true);
  • uspace/app/init/init.c

    r1522b42 r77cea41  
    5757#define DEVFS_MOUNT_POINT  "/dev"
    5858
    59 #define SCRATCH_FS_TYPE      "tmpfs"
    60 #define SCRATCH_MOUNT_POINT  "/scratch"
     59#define TMPFS_FS_TYPE      "tmpfs"
     60#define TMPFS_MOUNT_POINT  "/tmp"
    6161
    6262#define DATA_FS_TYPE      "fat"
     
    235235}
    236236
    237 static bool mount_scratch(void)
    238 {
    239         int rc = mount(SCRATCH_FS_TYPE, SCRATCH_MOUNT_POINT, "", "", 0);
    240         return mount_report("Scratch filesystem", SCRATCH_MOUNT_POINT,
    241             SCRATCH_FS_TYPE, NULL, rc);
     237static bool mount_tmpfs(void)
     238{
     239        int rc = mount(TMPFS_FS_TYPE, TMPFS_MOUNT_POINT, "", "", 0);
     240        return mount_report("Temporary filesystem", TMPFS_MOUNT_POINT,
     241            TMPFS_FS_TYPE, NULL, rc);
    242242}
    243243
     
    271271        }
    272272       
    273         mount_scratch();
     273        mount_tmpfs();
    274274       
    275275        spawn("/srv/fhc");
  • uspace/app/tester/Makefile

    r1522b42 r77cea41  
    5151        vfs/vfs1.c \
    5252        ipc/ping_pong.c \
    53         ipc/register.c \
    54         ipc/connect.c \
    5553        loop/loop1.c \
    5654        mm/malloc1.c \
  • uspace/app/tester/tester.c

    r1522b42 r77cea41  
    6060#include "vfs/vfs1.def"
    6161#include "ipc/ping_pong.def"
    62 #include "ipc/register.def"
    63 #include "ipc/connect.def"
    6462#include "loop/loop1.def"
    6563#include "mm/malloc1.def"
  • uspace/app/tester/tester.h

    r1522b42 r77cea41  
    7777extern const char *test_vfs1(void);
    7878extern const char *test_ping_pong(void);
    79 extern const char *test_register(void);
    80 extern const char *test_connect(void);
    8179extern const char *test_loop1(void);
    8280extern const char *test_malloc1(void);
  • uspace/app/tester/vfs/vfs1.c

    r1522b42 r77cea41  
    4040#include "../tester.h"
    4141
    42 #define FS_TYPE      "tmpfs"
    43 #define MOUNT_POINT  "/tmp"
    44 #define OPTIONS      ""
    45 #define FLAGS        0
    46 
    47 #define TEST_DIRECTORY  MOUNT_POINT "/testdir"
     42#define TEST_DIRECTORY  "/tmp/testdir"
    4843#define TEST_FILE       TEST_DIRECTORY "/testfile"
    4944#define TEST_FILE2      TEST_DIRECTORY "/nextfile"
     
    7570const char *test_vfs1(void)
    7671{
    77         if (mkdir(MOUNT_POINT, 0) != 0)
     72        int rc;
     73        if ((rc = mkdir(TEST_DIRECTORY, 0)) != 0) {
     74                TPRINTF("rc=%d\n", rc);
    7875                return "mkdir() failed";
    79         TPRINTF("Created directory %s\n", MOUNT_POINT);
    80        
    81         int rc = mount(FS_TYPE, MOUNT_POINT, "", OPTIONS, FLAGS);
    82         switch (rc) {
    83         case EOK:
    84                 TPRINTF("Mounted %s on %s\n", FS_TYPE, MOUNT_POINT);
    85                 break;
    86         case EBUSY:
    87                 TPRINTF("(INFO) Filesystem already mounted on %s\n", MOUNT_POINT);
    88                 break;
    89         default:
    90                 TPRINTF("(ERR) IPC returned errno %d (is tmpfs loaded?)\n", rc);
    91                 return "mount() failed";
    9276        }
    93        
    94         if (mkdir(TEST_DIRECTORY, 0) != 0)
    95                 return "mkdir() failed";
    9677        TPRINTF("Created directory %s\n", TEST_DIRECTORY);
    9778       
  • uspace/drv/ns8250/ns8250.c

    r1522b42 r77cea41  
    342342                printf(NAME ": failed to connect to the parent driver of the "
    343343                    "device %s.\n", dev->name);
    344                 ret = EPARTY;   /* FIXME: use another EC */
     344                ret = dev->parent_phone;
    345345                goto failed;
    346346        }
    347347       
    348348        /* Get hw resources. */
    349         if (!get_hw_resources(dev->parent_phone, &hw_resources)) {
     349        ret = get_hw_resources(dev->parent_phone, &hw_resources);
     350        if (ret != EOK) {
    350351                printf(NAME ": failed to get hw resources for the device "
    351352                    "%s.\n", dev->name);
    352                 ret = EPARTY;   /* FIXME: use another EC */
    353353                goto failed;
    354354        }
     
    374374                                printf(NAME ": i/o range assigned to the device "
    375375                                    "%s is too small.\n", dev->name);
    376                                 ret = EPARTY;   /* FIXME: use another EC */
     376                                ret = ELIMIT;
    377377                                goto failed;
    378378                        }
     
    390390                printf(NAME ": missing hw resource(s) for the device %s.\n",
    391391                    dev->name);
    392                 ret = EPARTY;   /* FIXME: use another EC */
     392                ret = ENOENT;
    393393                goto failed;
    394394        }
  • uspace/drv/pciintel/pci.c

    r1522b42 r77cea41  
    452452static int pci_add_device(device_t *dev)
    453453{
     454        int rc;
     455
    454456        printf(NAME ": pci_add_device\n");
    455457       
     
    466468                    "parent's driver.\n");
    467469                delete_pci_bus_data(bus_data);
    468                 return EPARTY;  /* FIXME: use another EC */
     470                return dev->parent_phone;
    469471        }
    470472       
    471473        hw_resource_list_t hw_resources;
    472474       
    473         if (!get_hw_resources(dev->parent_phone, &hw_resources)) {
     475        rc = get_hw_resources(dev->parent_phone, &hw_resources);
     476        if (rc != EOK) {
    474477                printf(NAME ": pci_add_device failed to get hw resources for "
    475478                    "the device.\n");
    476479                delete_pci_bus_data(bus_data);
    477480                ipc_hangup(dev->parent_phone);
    478                 return EPARTY;  /* FIXME: use another EC */
     481                return rc;
    479482        }       
    480483       
  • uspace/lib/c/generic/async_rel.c

    r1522b42 r77cea41  
    239239                 */
    240240retry:
    241                 rel_phone = ipc_connect_me_to(key_phone, 0, 0, 0);
     241                rel_phone = async_connect_me_to(key_phone, 0, 0, 0);
    242242                if (rel_phone >= 0) {
    243243                        /* success, do nothing */
  • uspace/lib/c/generic/device/hw_res.c

    r1522b42 r77cea41  
    3838#include <malloc.h>
    3939
    40 bool get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources)
     40int get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources)
    4141{
    4242        sysarg_t count = 0;
    4343        int rc = async_req_1_1(dev_phone, DEV_IFACE_ID(HW_RES_DEV_IFACE), GET_RESOURCE_LIST, &count);
    4444        hw_resources->count = count;
    45         if (EOK != rc) {
    46                 return false;
    47         }
     45        if (rc != EOK)
     46                return rc;
    4847       
    4948        size_t size = count * sizeof(hw_resource_t);
    5049        hw_resources->resources = (hw_resource_t *)malloc(size);
    51         if (NULL == hw_resources->resources) {
    52                 return false;
    53         }
     50        if (!hw_resources->resources)
     51                return ENOMEM;
    5452       
    5553        rc = async_data_read_start(dev_phone, hw_resources->resources, size);
    56         if (EOK != rc) {
     54        if (rc != EOK) {
    5755                free(hw_resources->resources);
    5856                hw_resources->resources = NULL;
    59                 return false;
     57                return rc;
    6058        }
    6159                 
    62         return true;     
     60        return EOK;
    6361}
    6462
  • uspace/lib/c/generic/devmap.c

    r1522b42 r77cea41  
    279279       
    280280        if (flags & IPC_FLAG_BLOCKING) {
    281                 phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP,
     281                phone = async_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP,
    282282                    DEVMAP_CONNECT_TO_DEVICE, handle);
    283283        } else {
    284                 phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
     284                phone = async_connect_me_to(PHONE_NS, SERVICE_DEVMAP,
    285285                    DEVMAP_CONNECT_TO_DEVICE, handle);
    286286        }
  • uspace/lib/c/generic/fibril_synch.c

    r1522b42 r77cea41  
    139139static void _fibril_mutex_unlock_unsafe(fibril_mutex_t *fm)
    140140{
    141         assert(fm->counter <= 0);
    142141        if (fm->counter++ < 0) {
    143142                link_t *tmp;
     
    165164void fibril_mutex_unlock(fibril_mutex_t *fm)
    166165{
     166        assert(fibril_mutex_is_locked(fm));
    167167        futex_down(&async_futex);
    168168        _fibril_mutex_unlock_unsafe(fm);
    169169        futex_up(&async_futex);
     170}
     171
     172bool fibril_mutex_is_locked(fibril_mutex_t *fm)
     173{
     174        bool locked = false;
     175       
     176        futex_down(&async_futex);
     177        if (fm->counter <= 0)
     178                locked = true;
     179        futex_up(&async_futex);
     180       
     181        return locked;
    170182}
    171183
     
    230242{
    231243        futex_down(&async_futex);
    232         assert(frw->readers || (frw->writers == 1));
    233244        if (frw->readers) {
    234245                if (--frw->readers) {
     
    296307void fibril_rwlock_read_unlock(fibril_rwlock_t *frw)
    297308{
     309        assert(fibril_rwlock_is_read_locked(frw));
    298310        _fibril_rwlock_common_unlock(frw);
    299311}
     
    301313void fibril_rwlock_write_unlock(fibril_rwlock_t *frw)
    302314{
     315        assert(fibril_rwlock_is_write_locked(frw));
    303316        _fibril_rwlock_common_unlock(frw);
     317}
     318
     319bool fibril_rwlock_is_read_locked(fibril_rwlock_t *frw)
     320{
     321        bool locked = false;
     322
     323        futex_down(&async_futex);
     324        if (frw->readers)
     325                locked = true;
     326        futex_up(&async_futex);
     327
     328        return locked;
     329}
     330
     331bool fibril_rwlock_is_write_locked(fibril_rwlock_t *frw)
     332{
     333        bool locked = false;
     334
     335        futex_down(&async_futex);
     336        if (frw->writers) {
     337                assert(frw->writers == 1);
     338                locked = true;
     339        }
     340        futex_up(&async_futex);
     341
     342        return locked;
     343}
     344
     345bool fibril_rwlock_is_locked(fibril_rwlock_t *frw)
     346{
     347        return fibril_rwlock_is_read_locked(frw) ||
     348            fibril_rwlock_is_write_locked(frw);
    304349}
    305350
     
    314359{
    315360        awaiter_t wdata;
     361
     362        assert(fibril_mutex_is_locked(fm));
    316363
    317364        if (timeout < 0)
  • uspace/lib/c/include/device/hw_res.h

    r1522b42 r77cea41  
    9595
    9696
    97 bool get_hw_resources(int dev_phone, hw_resource_list_t *hw_resources);
    98 
    99 bool enable_interrupt(int dev_phone);
     97extern int get_hw_resources(int, hw_resource_list_t *);
     98extern bool enable_interrupt(int);
    10099
    101100
  • uspace/lib/c/include/fibril_synch.h

    r1522b42 r77cea41  
    105105extern bool fibril_mutex_trylock(fibril_mutex_t *);
    106106extern void fibril_mutex_unlock(fibril_mutex_t *);
     107extern bool fibril_mutex_is_locked(fibril_mutex_t *);
    107108
    108109extern void fibril_rwlock_initialize(fibril_rwlock_t *);
     
    111112extern void fibril_rwlock_read_unlock(fibril_rwlock_t *);
    112113extern void fibril_rwlock_write_unlock(fibril_rwlock_t *);
     114extern bool fibril_rwlock_is_read_locked(fibril_rwlock_t *);
     115extern bool fibril_rwlock_is_write_locked(fibril_rwlock_t *);
     116extern bool fibril_rwlock_is_locked(fibril_rwlock_t *);
    113117
    114118extern void fibril_condvar_initialize(fibril_condvar_t *);
  • uspace/lib/packet/generic/packet_server.c

    r1522b42 r77cea41  
    135135/** Creates a new packet of dimensions at least as given.
    136136 *
    137  * Should be used only when the global data are locked.
    138  *
    139137 * @param[in] length    The total length of the packet, including the header,
    140138 *                      the addresses and the data of the packet.
     
    153151        packet_t *packet;
    154152        int rc;
     153
     154        assert(fibril_mutex_is_locked(&ps_globals.lock));
    155155
    156156        // already locked
     
    233233/** Release the packet and returns it to the appropriate free packet queue.
    234234 *
    235  * Should be used only when the global data are locked.
    236  *
    237235 * @param[in] packet    The packet to be released.
    238236 *
     
    242240        int index;
    243241        int result;
     242
     243        assert(fibril_mutex_is_locked(&ps_globals.lock));
    244244
    245245        for (index = 0; (index < FREE_QUEUES_COUNT - 1) &&
  • uspace/srv/devman/devman.c

    r1522b42 r77cea41  
    392392        printf(NAME ": create_root_node\n");
    393393
     394        fibril_rwlock_write_lock(&tree->rwlock);
    394395        node = create_dev_node();
    395396        if (node != NULL) {
     
    401402                tree->root_node = node;
    402403        }
     404        fibril_rwlock_write_unlock(&tree->rwlock);
    403405
    404406        return node != NULL;
     
    463465/** Start a driver
    464466 *
    465  * The driver's mutex is assumed to be locked.
    466  *
    467467 * @param drv           The driver's structure.
    468468 * @return              True if the driver's task is successfully spawned, false
     
    473473        int rc;
    474474
     475        assert(fibril_mutex_is_locked(&drv->driver_mutex));
     476       
    475477        printf(NAME ": start_driver '%s'\n", drv->name);
    476478       
     
    867869/** Find the device node structure of the device witch has the specified handle.
    868870 *
    869  * Device tree's rwlock should be held at least for reading.
    870  *
    871871 * @param tree          The device tree where we look for the device node.
    872872 * @param handle        The handle of the device.
     
    876876{
    877877        unsigned long key = handle;
    878         link_t *link = hash_table_find(&tree->devman_devices, &key);
     878        link_t *link;
     879       
     880        assert(fibril_rwlock_is_locked(&tree->rwlock));
     881       
     882        link = hash_table_find(&tree->devman_devices, &key);
    879883        return hash_table_get_instance(link, node_t, devman_link);
    880884}
     
    932936/** Insert new device into device tree.
    933937 *
    934  * The device tree's rwlock should be already held exclusively when calling this
    935  * function.
    936  *
    937938 * @param tree          The device tree.
    938939 * @param node          The newly added device node.
     
    949950        assert(tree != NULL);
    950951        assert(dev_name != NULL);
     952        assert(fibril_rwlock_is_write_locked(&tree->rwlock));
    951953       
    952954        node->name = dev_name;
  • uspace/srv/devmap/devmap.c

    r1522b42 r77cea41  
    4646#include <str.h>
    4747#include <ipc/devmap.h>
     48#include <assert.h>
    4849
    4950#define NAME          "devmap"
     
    208209}
    209210
    210 /** Find namespace with given name.
    211  *
    212  * The devices_list_mutex should be already held when
    213  * calling this function.
    214  *
    215  */
     211/** Find namespace with given name. */
    216212static devmap_namespace_t *devmap_namespace_find_name(const char *name)
    217213{
    218214        link_t *item;
     215       
     216        assert(fibril_mutex_is_locked(&devices_list_mutex));
     217       
    219218        for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {
    220219                devmap_namespace_t *namespace =
     
    229228/** Find namespace with given handle.
    230229 *
    231  * The devices_list_mutex should be already held when
    232  * calling this function.
    233  *
    234230 * @todo: use hash table
    235231 *
     
    238234{
    239235        link_t *item;
     236       
     237        assert(fibril_mutex_is_locked(&devices_list_mutex));
     238       
    240239        for (item = namespaces_list.next; item != &namespaces_list; item = item->next) {
    241240                devmap_namespace_t *namespace =
     
    248247}
    249248
    250 /** Find device with given name.
    251  *
    252  * The devices_list_mutex should be already held when
    253  * calling this function.
    254  *
    255  */
     249/** Find device with given name. */
    256250static devmap_device_t *devmap_device_find_name(const char *ns_name,
    257251    const char *name)
    258252{
    259253        link_t *item;
     254       
     255        assert(fibril_mutex_is_locked(&devices_list_mutex));
     256       
    260257        for (item = devices_list.next; item != &devices_list; item = item->next) {
    261258                devmap_device_t *device =
     
    271268/** Find device with given handle.
    272269 *
    273  * The devices_list_mutex should be already held when
    274  * calling this function.
    275  *
    276270 * @todo: use hash table
    277271 *
     
    280274{
    281275        link_t *item;
     276       
     277        assert(fibril_mutex_is_locked(&devices_list_mutex));
     278       
    282279        for (item = devices_list.next; item != &devices_list; item = item->next) {
    283280                devmap_device_t *device =
     
    290287}
    291288
    292 /** Create a namespace (if not already present)
    293  *
    294  * The devices_list_mutex should be already held when
    295  * calling this function.
    296  *
    297  */
     289/** Create a namespace (if not already present). */
    298290static devmap_namespace_t *devmap_namespace_create(const char *ns_name)
    299291{
    300         devmap_namespace_t *namespace = devmap_namespace_find_name(ns_name);
     292        devmap_namespace_t *namespace;
     293       
     294        assert(fibril_mutex_is_locked(&devices_list_mutex));
     295       
     296        namespace = devmap_namespace_find_name(ns_name);
    301297        if (namespace != NULL)
    302298                return namespace;
     
    323319}
    324320
    325 /** Destroy a namespace (if it is no longer needed)
    326  *
    327  * The devices_list_mutex should be already held when
    328  * calling this function.
    329  *
    330  */
     321/** Destroy a namespace (if it is no longer needed). */
    331322static void devmap_namespace_destroy(devmap_namespace_t *namespace)
    332323{
     324        assert(fibril_mutex_is_locked(&devices_list_mutex));
     325
    333326        if (namespace->refcnt == 0) {
    334327                list_remove(&(namespace->namespaces));
     
    339332}
    340333
    341 /** Increase namespace reference count by including device
    342  *
    343  * The devices_list_mutex should be already held when
    344  * calling this function.
    345  *
    346  */
     334/** Increase namespace reference count by including device. */
    347335static void devmap_namespace_addref(devmap_namespace_t *namespace,
    348336    devmap_device_t *device)
    349337{
     338        assert(fibril_mutex_is_locked(&devices_list_mutex));
     339
    350340        device->namespace = namespace;
    351341        namespace->refcnt++;
    352342}
    353343
    354 /** Decrease namespace reference count
    355  *
    356  * The devices_list_mutex should be already held when
    357  * calling this function.
    358  *
    359  */
     344/** Decrease namespace reference count. */
    360345static void devmap_namespace_delref(devmap_namespace_t *namespace)
    361346{
     347        assert(fibril_mutex_is_locked(&devices_list_mutex));
     348
    362349        namespace->refcnt--;
    363350        devmap_namespace_destroy(namespace);
    364351}
    365352
    366 /** Unregister device and free it
    367  *
    368  * The devices_list_mutex should be already held when
    369  * calling this function.
    370  *
    371  */
     353/** Unregister device and free it. */
    372354static void devmap_device_unregister_core(devmap_device_t *device)
    373355{
     356        assert(fibril_mutex_is_locked(&devices_list_mutex));
     357
    374358        devmap_namespace_delref(device->namespace);
    375359        list_remove(&(device->devices));
  • uspace/srv/fs/devfs/devfs_ops.c

    r1522b42 r77cea41  
    6060typedef struct {
    6161        devmap_handle_t handle;
    62         int phone;
     62        int phone;              /**< When < 0, the structure is incomplete. */
    6363        size_t refcount;
    6464        link_t link;
     65        fibril_condvar_t cv;    /**< Broadcast when completed. */
    6566} device_t;
    6667
     
    227228                        [DEVICES_KEY_HANDLE] = (unsigned long) node->handle
    228229                };
    229                
     230                link_t *lnk;
     231
    230232                fibril_mutex_lock(&devices_mutex);
    231                 link_t *lnk = hash_table_find(&devices, key);
     233restart:
     234                lnk = hash_table_find(&devices, key);
    232235                if (lnk == NULL) {
    233236                        device_t *dev = (device_t *) malloc(sizeof(device_t));
     
    237240                        }
    238241                       
     242                        dev->handle = node->handle;
     243                        dev->phone = -1;        /* mark as incomplete */
     244                        dev->refcount = 1;
     245                        fibril_condvar_initialize(&dev->cv);
     246
     247                        /*
     248                         * Insert the incomplete device structure so that other
     249                         * fibrils will not race with us when we drop the mutex
     250                         * below.
     251                         */
     252                        hash_table_insert(&devices, key, &dev->link);
     253
     254                        /*
     255                         * Drop the mutex to allow recursive devfs requests.
     256                         */
     257                        fibril_mutex_unlock(&devices_mutex);
     258
    239259                        int phone = devmap_device_connect(node->handle, 0);
     260
     261                        fibril_mutex_lock(&devices_mutex);
     262
     263                        /*
     264                         * Notify possible waiters about this device structure
     265                         * being completed (or destroyed).
     266                         */
     267                        fibril_condvar_broadcast(&dev->cv);
     268
    240269                        if (phone < 0) {
     270                                /*
     271                                 * Connecting failed, need to remove the
     272                                 * entry and free the device structure.
     273                                 */
     274                                hash_table_remove(&devices, key, DEVICES_KEYS);
    241275                                fibril_mutex_unlock(&devices_mutex);
     276
    242277                                free(dev);
    243278                                return ENOENT;
    244279                        }
    245280                       
    246                         dev->handle = node->handle;
     281                        /* Set the correct phone. */
    247282                        dev->phone = phone;
    248                         dev->refcount = 1;
    249                        
    250                         hash_table_insert(&devices, key, &dev->link);
    251283                } else {
    252284                        device_t *dev = hash_table_get_instance(lnk, device_t, link);
     285
     286                        if (dev->phone < 0) {
     287                                /*
     288                                 * Wait until the device structure is completed
     289                                 * and start from the beginning as the device
     290                                 * structure might have entirely disappeared
     291                                 * while we were not holding the mutex in
     292                                 * fibril_condvar_wait().
     293                                 */
     294                                fibril_condvar_wait(&dev->cv, &devices_mutex);
     295                                goto restart;
     296                        }
     297
    253298                        dev->refcount++;
    254299                }
     
    564609               
    565610                device_t *dev = hash_table_get_instance(lnk, device_t, link);
     611                assert(dev->phone >= 0);
    566612               
    567613                ipc_callid_t callid;
     
    627673               
    628674                device_t *dev = hash_table_get_instance(lnk, device_t, link);
     675                assert(dev->phone >= 0);
    629676               
    630677                ipc_callid_t callid;
     
    696743               
    697744                device_t *dev = hash_table_get_instance(lnk, device_t, link);
     745                assert(dev->phone >= 0);
    698746                dev->refcount--;
    699747               
     
    743791               
    744792                device_t *dev = hash_table_get_instance(lnk, device_t, link);
     793                assert(dev->phone >= 0);
    745794               
    746795                /* Make a request at the driver */
  • uspace/srv/net/tl/tcp/tcp.c

    r1522b42 r77cea41  
    20852085        if (!fibril) {
    20862086                free(operation_timeout);
    2087                 return EPARTY;  /* FIXME: use another EC */
    2088         }
     2087                return ENOMEM;
     2088        }
     2089
    20892090//      fibril_mutex_lock(&socket_data->operation.mutex);
    20902091        /* Start the timeout fibril */
  • uspace/srv/vfs/vfs_lookup.c

    r1522b42 r77cea41  
    179179        fibril_mutex_unlock(&plb_mutex);
    180180       
    181         if (((int) rc < EOK) || (!result))
     181        if ((int) rc < EOK)
    182182                return (int) rc;
     183
     184        if (!result)
     185                return EOK;
    183186       
    184187        result->triplet.fs_handle = (fs_handle_t) rc;
Note: See TracChangeset for help on using the changeset viewer.