Fix `ff_fdused_range` not work.

This commit is contained in:
logwang 2017-08-08 23:47:38 +08:00
parent a02c88d651
commit 615f2d3c02
5 changed files with 9 additions and 7 deletions

View File

@ -105,7 +105,7 @@ int main(int argc, char * argv[])
{ {
ff_init(argc, argv); ff_init(argc, argv);
int sockfd = ff_socket(AF_INET, SOCK_STREAM, 0); sockfd = ff_socket(AF_INET, SOCK_STREAM, 0);
printf("sockfd:%d\n", sockfd); printf("sockfd:%d\n", sockfd);
if (sockfd < 0) if (sockfd < 0)
printf("ff_socket failed\n"); printf("ff_socket failed\n");

View File

@ -4122,12 +4122,12 @@ ff_fdisused(int fd)
* the kernel's descriptor space * the kernel's descriptor space
*/ */
void void
ff_fdused_range(struct filedesc *fdp, int max) ff_fdused_range(int max)
{ {
int i; int i, result;
struct thread *td = curthread;
for (i = 0; i < max; i++) for (i = 0; i < max; i++)
fdused(fdp, i); fdalloc(td, 0, &result);
} }
#endif #endif

View File

@ -285,6 +285,8 @@ ini_parse_handler(void* user, const char* section, const char* name,
pconfig->freebsd.hz = atoi(value); pconfig->freebsd.hz = atoi(value);
} else if (strcmp(name, "physmem") == 0) { } else if (strcmp(name, "physmem") == 0) {
pconfig->freebsd.physmem = atol(value); pconfig->freebsd.physmem = atol(value);
} else if (strcmp(name, "fd_reserve") == 0) {
pconfig->freebsd.fd_reserve = atoi(value);
} else { } else {
return freebsd_conf_handler(pconfig, "boot", name, value); return freebsd_conf_handler(pconfig, "boot", name, value);
} }

View File

@ -112,7 +112,7 @@ ff_freebsd_init(void)
mutex_init(); mutex_init();
mi_startup(); mi_startup();
sx_init(&proctree_lock, "proctree"); sx_init(&proctree_lock, "proctree");
ff_fdused_range(curthread->td_proc->p_fd, ff_global_cfg.freebsd.fd_reserve); ff_fdused_range(ff_global_cfg.freebsd.fd_reserve);
cur = ff_global_cfg.freebsd.sysctl; cur = ff_global_cfg.freebsd.sysctl;
while (cur) { while (cur) {

View File

@ -30,7 +30,7 @@
#include_next <sys/filedesc.h> #include_next <sys/filedesc.h>
void ff_fdused_range(struct filedesc *fdp, int max); void ff_fdused_range(int max);
int ff_fdisused(int fd); int ff_fdisused(int fd);
#endif /* _FSTACK_SYS_FILEDESC_H_ */ #endif /* _FSTACK_SYS_FILEDESC_H_ */