Changeset 34ca870 in mainline for uspace/srv/vfs/vfs_register.c


Ignore:
Timestamp:
2009-06-17T21:07:56Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6ebe721
Parents:
61d2315
Message:

Handle each VFS request using a dedicated connection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs_register.c

    r61d2315 r34ca870  
    286286int vfs_grab_phone(fs_handle_t handle)
    287287{
    288         /*
    289          * For now, we don't try to be very clever and very fast.
    290          * We simply lookup the phone in the fs_head list. We currently don't
    291          * open any additional phones (even though that itself would be pretty
    292          * straightforward; housekeeping multiple open phones to a FS task would
    293          * be more demanding). Instead, we simply take the respective
    294          * phone_futex and keep it until vfs_release_phone().
     288        int phone;
     289
     290        /*
     291         * For now, we don't try to be very clever and very fast.  We simply
     292         * lookup the phone in the fs_head list and duplicate it.  The duplicate
     293         * phone will be returned to the client and the client will use it for
     294         * communication.  In the future, we should cache the connections so
     295         * that they do not have to be reestablished over and over again.
    295296         */
    296297        fibril_mutex_lock(&fs_head_lock);
     
    302303                        fibril_mutex_unlock(&fs_head_lock);
    303304                        fibril_mutex_lock(&fs->phone_lock);
    304                         return fs->phone;
     305                        phone = ipc_connect_me_to(fs->phone, 0, 0, 0);
     306                        fibril_mutex_unlock(&fs->phone_lock);
     307
     308                        assert(phone > 0);
     309                        return phone;
    305310                }
    306311        }
     
    309314}
    310315
    311 /** Tell VFS that the phone is in use for any request.
     316/** Tell VFS that the phone is not needed anymore.
    312317 *
    313318 * @param phone         Phone to FS task.
     
    315320void vfs_release_phone(int phone)
    316321{
    317         bool found = false;
    318 
    319         fibril_mutex_lock(&fs_head_lock);
    320         link_t *cur;
    321         for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
    322                 fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link);
    323                 if (fs->phone == phone) {
    324                         found = true;
    325                         fibril_mutex_unlock(&fs_head_lock);
    326                         fibril_mutex_unlock(&fs->phone_lock);
    327                         return;
    328                 }
    329         }
    330         fibril_mutex_unlock(&fs_head_lock);
    331 
    332         /*
    333          * Not good to get here.
    334          */
    335         assert(found == true);
     322        /* TODO: implement connection caching */
     323        ipc_hangup(phone);
    336324}
    337325
Note: See TracChangeset for help on using the changeset viewer.