Changeset 4fe94c66 in mainline for uspace/srv/vfs/vfs_ops.c


Ignore:
Timestamp:
2011-01-26T00:57:06Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
12573db, bf75e3cb
Parents:
8b65e547
Message:

Now when the table of open files is shared by multiple connections of
one client task, it became necessary to maintain the vfs_file_t
references obtained from vfs_file_get() explicitly.

File:
1 edited

Legend:

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

    r8b65e547 r4fe94c66  
    604604        vfs_node_addref(node);
    605605        vfs_node_put(node);
     606        vfs_file_put(file);
    606607       
    607608        /* Success! Return the new file descriptor to the client. */
     
    676677        vfs_node_addref(node);
    677678        vfs_node_put(node);
     679        vfs_file_put(file);
    678680       
    679681        /* Success! Return the new file descriptor to the client. */
     
    711713        vfs_release_phone(file->node->fs_handle, fs_phone);
    712714        fibril_mutex_unlock(&file->lock);
    713        
     715
     716        vfs_file_put(file);
    714717        ipc_answer_0(rid, rc);
    715718}
     
    765768                ipc_answer_0(rid, ret);
    766769       
     770        vfs_file_put(file);
    767771        ret = vfs_fd_free(fd);
    768772        ipc_answer_0(rid, ret);
     
    865869                file->pos += bytes;
    866870        fibril_mutex_unlock(&file->lock);
    867        
     871        vfs_file_put(file);     
     872
    868873        /*
    869874         * FS server's reply is the final result of the whole operation we
     
    905910                        file->pos = (aoff64_t) off;
    906911                        fibril_mutex_unlock(&file->lock);
     912                        vfs_file_put(file);
    907913                        ipc_answer_1(rid, EOK, off);
    908914                        return;
     
    912918                if ((off >= 0) && (file->pos + off < file->pos)) {
    913919                        fibril_mutex_unlock(&file->lock);
     920                        vfs_file_put(file);
    914921                        ipc_answer_0(rid, EOVERFLOW);
    915922                        return;
     
    918925                if ((off < 0) && (file->pos < (aoff64_t) -off)) {
    919926                        fibril_mutex_unlock(&file->lock);
     927                        vfs_file_put(file);
    920928                        ipc_answer_0(rid, EOVERFLOW);
    921929                        return;
     
    926934               
    927935                fibril_mutex_unlock(&file->lock);
     936                vfs_file_put(file);
    928937                ipc_answer_2(rid, EOK, LOWER32(newoff),
    929938                    UPPER32(newoff));
     
    936945                        fibril_rwlock_read_unlock(&file->node->contents_rwlock);
    937946                        fibril_mutex_unlock(&file->lock);
     947                        vfs_file_put(file);
    938948                        ipc_answer_0(rid, EOVERFLOW);
    939949                        return;
     
    943953                        fibril_rwlock_read_unlock(&file->node->contents_rwlock);
    944954                        fibril_mutex_unlock(&file->lock);
     955                        vfs_file_put(file);
    945956                        ipc_answer_0(rid, EOVERFLOW);
    946957                        return;
     
    952963                fibril_rwlock_read_unlock(&file->node->contents_rwlock);
    953964                fibril_mutex_unlock(&file->lock);
     965                vfs_file_put(file);
    954966                ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
    955967                return;
     
    957969       
    958970        fibril_mutex_unlock(&file->lock);
     971        vfs_file_put(file);
    959972        ipc_answer_0(rid, EINVAL);
    960973}
     
    9951008
    9961009        fibril_mutex_unlock(&file->lock);
     1010        vfs_file_put(file);
    9971011        ipc_answer_0(rid, (sysarg_t)rc);
    9981012}
     
    10111025        ipc_callid_t callid;
    10121026        if (!async_data_read_receive(&callid, NULL)) {
     1027                vfs_file_put(file);
    10131028                ipc_answer_0(callid, EINVAL);
    10141029                ipc_answer_0(rid, EINVAL);
     
    10281043
    10291044        fibril_mutex_unlock(&file->lock);
     1045        vfs_file_put(file);
    10301046        ipc_answer_0(rid, rc);
    10311047}
     
    13291345        int newfd = IPC_GET_ARG2(*request);
    13301346       
     1347        /* If the file descriptors are the same, do nothing. */
     1348        if (oldfd == newfd) {
     1349                ipc_answer_1(rid, EOK, newfd);
     1350                return;
     1351        }
     1352       
    13311353        /* Lookup the file structure corresponding to oldfd. */
    13321354        vfs_file_t *oldfile = vfs_file_get(oldfd);
    13331355        if (!oldfile) {
    13341356                ipc_answer_0(rid, EBADF);
    1335                 return;
    1336         }
    1337        
    1338         /* If the file descriptors are the same, do nothing. */
    1339         if (oldfd == newfd) {
    1340                 ipc_answer_1(rid, EOK, newfd);
    13411357                return;
    13421358        }
     
    13551371                if (ret != EOK) {
    13561372                        fibril_mutex_unlock(&oldfile->lock);
     1373                        vfs_file_put(oldfile);
     1374                        vfs_file_put(newfile);
    13571375                        ipc_answer_0(rid, ret);
    13581376                        return;
     
    13621380                if (ret != EOK) {
    13631381                        fibril_mutex_unlock(&oldfile->lock);
     1382                        vfs_file_put(oldfile);
     1383                        vfs_file_put(newfile);
    13641384                        ipc_answer_0(rid, ret);
    13651385                        return;
    13661386                }
     1387                vfs_file_put(newfile);
    13671388        }
    13681389       
     
    13701391        int ret = vfs_fd_assign(oldfile, newfd);
    13711392        fibril_mutex_unlock(&oldfile->lock);
     1393        vfs_file_put(oldfile);
    13721394       
    13731395        if (ret != EOK)
Note: See TracChangeset for help on using the changeset viewer.