linux - linux 文件描述符限制如何工作?

标签 linux sockets file file-descriptor

有人告诉我,我的服务器拒绝在特定端口接受客户端网络连接,这可能是由于缺少文件描述符。我查了一下这是怎么回事,并在这里阅读:http://www.netadmintools.com/art295.html

所以我测试了我的系统,我得到了这个:

cat /proc/sys/fs/file-nr
1088    0   331287

这是什么意思?

即使在我关闭服务器后,第二列实际上仍保持为 0,甚至在启动后它甚至仍保持在 0!

最佳答案

你想看看/proc/sys/fs/file-max

来自最近的 linux/Documentation/sysctl/fs.txt:

file-max & file-nr:

The kernel allocates file handles dynamically, but as yet it doesn't free them again.

The value in file-max denotes the maximum number of file- handles that the Linux kernel will allocate. When you get lots of error messages about running out of file handles, you might want to increase this limit.

Historically, the three values in file-nr denoted the number of allocated file handles, the number of allocated but unused file handles, and the maximum number of file handles. Linux 2.6 always reports 0 as the number of free file handles -- this is not an error, it just means that the number of allocated file handles exactly matches the number of used file handles.

Attempts to allocate more file descriptors than file-max are reported with printk, look for "VFS: file-max limit reached".

编辑:根本错误可能不是系统用完了全局文件描述符,而是您的进程。问题似乎是 maximum size limit of select .

关于linux - linux 文件描述符限制如何工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3991223/

相关文章:

node.js - 非虚拟机 : Cannot uninstall currently-active node version

linux - 当 tar 找不到容器文件系统时 docker swarm create 失败

linux - 在 Linux/UNIX 中加入 pthreads 的主要目的是什么?

java - 短信UDP应用

c# - 定期从网络共享文件夹中读取文件的最有效方法是什么?

c - 如何在文件C中搜索并替换字符串

c++ - CPPPATH 似乎不适用于 scons?

python - 由 multiprocessing.Manager() 启动的服务器进程使管道套接字不会立即关闭

java - 为在线多人游戏构建服务器

c - 关于锁定 fread/fwrite 并从不同进程调用