mirror of
https://github.com/ericonr/sndio.git
synced 2024-02-18 04:45:21 -06:00
properly count file descriptors
This commit is contained in:
parent
526f2d2b92
commit
84d21ff8c2
@ -221,8 +221,7 @@ file_new(struct fileops *ops, void *arg, char *name, unsigned int nfds)
|
|||||||
{
|
{
|
||||||
struct file *f;
|
struct file *f;
|
||||||
|
|
||||||
file_nfds += nfds;
|
if (file_nfds + nfds > MAXFDS) {
|
||||||
if (file_nfds > MAXFDS) {
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (log_level >= 1) {
|
if (log_level >= 1) {
|
||||||
log_puts(name);
|
log_puts(name);
|
||||||
@ -232,6 +231,7 @@ file_new(struct fileops *ops, void *arg, char *name, unsigned int nfds)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
f = xmalloc(sizeof(struct file));
|
f = xmalloc(sizeof(struct file));
|
||||||
|
f->nfds = nfds;
|
||||||
f->ops = ops;
|
f->ops = ops;
|
||||||
f->arg = arg;
|
f->arg = arg;
|
||||||
f->name = name;
|
f->name = name;
|
||||||
@ -244,6 +244,7 @@ file_new(struct fileops *ops, void *arg, char *name, unsigned int nfds)
|
|||||||
log_puts(": created\n");
|
log_puts(": created\n");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
file_nfds += f->nfds;
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,6 +257,7 @@ file_del(struct file *f)
|
|||||||
panic();
|
panic();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
file_nfds -= f->nfds;
|
||||||
f->state = FILE_ZOMB;
|
f->state = FILE_ZOMB;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (log_level >= 3) {
|
if (log_level >= 3) {
|
||||||
|
Loading…
Reference in New Issue
Block a user