0

My program use a main thread accept comming connections(so there is no accept racing!),then give it to 4 slave threads ,they will close when r/w return 0.

but some times the log print like this.....

Feb 27 00:13:31 mx59  lp_server.c[62] __lp_listening_handler: "<-1195489312> [INFO] accept fd(105), ready for register, inode(-1031324988)"
Feb 27 00:13:31 mx59  lp_server.c[69] __lp_listening_handler: "<-1195489312> [INFO] ldapproxy accept new connection succ!"
Feb 27 00:13:33 mx59  lp_server.c[62] __lp_listening_handler: "<-1195489312> [INFO] accept fd(105), ready for register, inode(-1031324792)"
Feb 27 00:13:33 mx59  lp_server.c[69] __lp_listening_handler: "<-1195489312> [INFO] ldapproxy accept new connection succ!"
Feb 27 00:13:33 mx59  lp_ldap.c[603] lp_ldap_io_event_handler: "<-1217919232> [INFO] task type: ..., ..."
Feb 27 00:13:36 mx59  lp_server.c[62] __lp_listening_handler: "<-1195489312> [INFO] accept fd(105), ready for register, inode(-1031324295)"
Feb 27 00:13:36 mx59  lp_server.c[69] __lp_listening_handler: "<-1195489312> [INFO] ldapproxy accept new connection succ!"
Feb 27 00:13:38 mx59  lp_server.c[62] __lp_listening_handler: "<-1195489312> [INFO] accept fd(105), ready for register, inode(-1031324102)"
Feb 27 00:13:38 mx59  lp_server.c[69] __lp_listening_handler: "<-1195489312> [INFO] ldapproxy accept new connection succ!"
Feb 27 00:13:38 mx59  lp_ldap.c[603] lp_ldap_io_event_handler: "<-1196939520> [INFO] task type: ..., ..."
Feb 27 00:13:41 mx59  lp_server.c[62] __lp_listening_handler: "<-1195489312> [INFO] accept fd(105), ready for register, inode(-1031323906)"
Feb 27 00:13:41 mx59  lp_server.c[69] __lp_listening_handler: "<-1195489312> [INFO] ldapproxy accept new connection succ!"
Feb 27 00:13:43 mx59  lp_server.c[62] __lp_listening_handler: "<-1195489312> [INFO] accept fd(105), ready for register, inode(-1031323852)"
Feb 27 00:13:43 mx59  lp_server.c[69] __lp_listening_handler: "<-1195489312> [INFO] ldapproxy accept new connection succ!"
Feb 27 00:13:43 mx59  lp_ldap.c[603] lp_ldap_io_event_handler: "<-1217919232> [INFO] task type: ..., ..."
Feb 27 00:13:46 mx59  lp_server.c[62] __lp_listening_handler: "<-1195489312> [INFO] accept fd(105), ready for register, inode(-1031323694)"

there are some points to be pointed out: 1)fd 105 used more then one time(inode different),but i see no connetion closing info!

2)Some time after the log above,program printing "accept fail" all the time.

I check and see "cat /proc/$pid/fd/*|wc -l == ulimit -n",that is: not long after this log,open fds reaches the current limitation.

Is there any relation between the log pasted above and the "accept fail"?

3)or just the syslog-ng bugs so it did’nt print connection closing info?

alk
  • 69,737
  • 10
  • 105
  • 255
aishuishou
  • 83
  • 7
  • you could start by posting the code. Have you ran it with a debugger? How large a 'pool' of children did you create? what is the limit you gave to accept/listen? how fast are new connections being made? it seems highly probable that not all the children are properly exiting. Have you looked at the process list to see how many children are still running? – user3629249 Feb 28 '15 at 04:59
  • Try running it "single" threaded (1 slave only) and see if it works well. If not debug the signle thread session using a debugger. – alk Feb 28 '15 at 07:24
  • "*or just the syslog-ng bugs so it did’nt print connection closing info*" very unlikely. Add your own `fprintf(stderr, "closing fd %d", fd)` – alk Feb 28 '15 at 07:26
  • Also when is comes to log an fd with value 100something, are you sure there ougth to be some around 100 other connections open? – alk Feb 28 '15 at 07:29
  • file/socket descriptors are a limited resource, so if not closing them when not used anymore the process will run out of free ones. – alk Feb 28 '15 at 07:31
  • Also log the value of `errno` in case a system call fails. – alk Feb 28 '15 at 07:32

0 Answers0