more name cleanup
This commit is contained in:
parent
6f2b626d28
commit
4ed974f5ea
2 changed files with 8 additions and 10 deletions
16
fd.c
16
fd.c
|
@ -37,7 +37,7 @@ fd_alloc()
|
||||||
for(i = 0; i < NFD; i++){
|
for(i = 0; i < NFD; i++){
|
||||||
if(fds[i].type == FD_CLOSED){
|
if(fds[i].type == FD_CLOSED){
|
||||||
fds[i].type = FD_NONE;
|
fds[i].type = FD_NONE;
|
||||||
fds[i].count = 1;
|
fds[i].ref = 1;
|
||||||
release(&fd_table_lock);
|
release(&fd_table_lock);
|
||||||
return fds + i;
|
return fds + i;
|
||||||
}
|
}
|
||||||
|
@ -80,18 +80,16 @@ fd_close(struct fd *fd)
|
||||||
{
|
{
|
||||||
acquire(&fd_table_lock);
|
acquire(&fd_table_lock);
|
||||||
|
|
||||||
if(fd->count < 1 || fd->type == FD_CLOSED)
|
if(fd->ref < 1 || fd->type == FD_CLOSED)
|
||||||
panic("fd_close");
|
panic("fd_close");
|
||||||
|
|
||||||
fd->count -= 1;
|
if(--fd->ref == 0){
|
||||||
|
|
||||||
if(fd->count == 0){
|
|
||||||
if(fd->type == FD_PIPE){
|
if(fd->type == FD_PIPE){
|
||||||
pipe_close(fd->pipe, fd->writeable);
|
pipe_close(fd->pipe, fd->writeable);
|
||||||
} else {
|
} else {
|
||||||
panic("fd_close");
|
panic("fd_close");
|
||||||
}
|
}
|
||||||
fd->count = 0;
|
fd->ref = 0;
|
||||||
fd->type = FD_CLOSED;
|
fd->type = FD_CLOSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,8 +100,8 @@ void
|
||||||
fd_incref(struct fd *fd)
|
fd_incref(struct fd *fd)
|
||||||
{
|
{
|
||||||
acquire(&fd_table_lock);
|
acquire(&fd_table_lock);
|
||||||
if(fd->count < 1 || fd->type == FD_CLOSED)
|
if(fd->ref < 1 || fd->type == FD_CLOSED)
|
||||||
panic("fd_reference");
|
panic("fd_incref");
|
||||||
fd->count++;
|
fd->ref++;
|
||||||
release(&fd_table_lock);
|
release(&fd_table_lock);
|
||||||
}
|
}
|
||||||
|
|
2
fd.h
2
fd.h
|
@ -1,6 +1,6 @@
|
||||||
struct fd {
|
struct fd {
|
||||||
enum { FD_CLOSED, FD_NONE, FD_PIPE } type;
|
enum { FD_CLOSED, FD_NONE, FD_PIPE } type;
|
||||||
int count; // reference count
|
int ref; // reference count
|
||||||
char readable;
|
char readable;
|
||||||
char writeable;
|
char writeable;
|
||||||
struct pipe *pipe;
|
struct pipe *pipe;
|
||||||
|
|
Loading…
Reference in a new issue