报错如下:
LOG save error!LogFd =NULL ,errno 24,reason = Too many open files
上面的错误,使用如下打印的:
printf("LOG save error!LogFd =NULL ,errno %d,reason = %s\n", errno, strerror(errno));
可以看到提示说,打开的太多了,没法再打开了。
排查
执行lsof命令可以查看当前的状态:
lsof
我查到如下:
30569 webs socket:[185909] 30569 webs socket:[182108] 30569 webs socket:[185939] 30569 webs socket:[185960] 30569 webs socket:[185982] 30569 webs socket:[186003] 30569 webs socket:[186023] 30569 webs socket:[186039] 30569 webs socket:[186058] 30569 webs socket:[186068] 30569 webs socket:[186090] 30569 webs socket:[186105] 30569 webs socket:[186123] 30569 webs socket:[186142] 30569 webs socket:[186156] 30569 webs socket:[186175] 30569 webs socket:[186194] 30569 webs socket:[186210] 30569 webs socket:[187576] 30569 webs socket:[186236] 30569 webs socket:[186257] 30569 webs socket:[187654] 30569 webs socket:[187678] 30569 webs socket:[186310] 30569 webs socket:[186328] 30569 webs socket:[186339] 30569 webs socket:[186357] 30569 webs socket:[189446] 30569 webs socket:[189462] 30569 webs socket:[189483] 30569 webs socket:[189496] 30569 webs socket:[189513] 30569 webs socket:[189522] 30569 webs socket:[189541] 30569 webs socket:[189560] 30569 webs socket:[189575] 30569 webs socket:[190498] 30569 webs socket:[189600] 30569 webs socket:[189609] 30569 webs socket:[189624] 30569 webs socket:[189641] 30569 webs socket:[189658] 30569 webs socket:[189678] 30569 webs socket:[188315] 30569 webs socket:[189713] 30569 webs socket:[190576] 30569 webs socket:[190604] 30569 webs socket:[189787] 30569 webs socket:[190665] 30569 webs socket:[189832] 30569 webs socket:[189846] 30569 webs socket:[189853] 30569 webs socket:[189873] 30569 webs socket:[189884] 30569 webs socket:[189907] 30569 webs socket:[189921] 30569 webs socket:[192766] 30569 webs socket:[189953] 30569 webs socket:[192803] 30569 webs socket:[189986] 30569 webs socket:[190005] 30569 webs socket:[190021] 30569 webs socket:[192912] 30569 webs socket:[190053] 30569 webs socket:[190072] 30569 webs socket:[190088] 30569 webs socket:[193029] 30569 webs socket:[190121] 30569 webs socket:[190134] 30569 webs socket:[193102] 30569 webs socket:[190162] 30569 webs socket:[190179] 30569 webs socket:[190196] 30569 webs socket:[190213] 30569 webs socket:[190229] 30569 webs socket:[190250] 30569 webs socket:[190271] 30569 webs socket:[190858] 30569 webs socket:[190310] 30569 webs socket:[190329] 30569 webs socket:[190336] 30569 webs socket:[190966] 30569 webs socket:[190365] 30569 webs socket:[190384] 30569 webs socket:[190401] 30569 webs socket:[190420] 30569 webs socket:[190441] 30569 webs socket:[190458] 30569 webs socket:[195597] 30569 webs socket:[195615]
一直在增加,过几秒增加一次。
经过排查,是socket的问题。
因为每隔几秒,就会使用socket函数获取一下ip造成的。
使用的是close函数关闭的。
又检查了下,是因为close函数没有彻底关闭掉socket导致的一直增加句柄的操作。