0

I write a script to change the hostapd mode ap to sta and sta to ap which lasts running for serval hours and the process of netifd hanged up.

cat proc/id/maps


0400000-0041f000 r-xp 00000000 1f:06 1176       /sbin/netifd
0042f000-00430000 rw-p 0001f000 1f:06 1176       /sbin/netifd
**00430000-00476000 rwxp 00000000 00:00 0          [heap]**
772af000-7730a000 r-xp 00000000 1f:06 144        /lib/libuClibc-0.9.33.2.so

00400000-0041f000 r-xp 00000000 1f:06 1176       /sbin/netifd
0042f000-00430000 rw-p 0001f000 1f:06 1176       /sbin/netifd
**00430000-00477000 rwxp 00000000 00:00 0          [heap]**
772af000-7730a000 r-xp 00000000 1f:06 144        /lib/libuClibc-0.9.33.2.so

I find that heap of the process is constantly rising. could not fix it.

Change mode of ap, hostapd will teardown and setup. and the process heap of netifd is rising.

finally it cause

netifd/wireless.c 
wireless_device_run_handler()->netifd_start_process()

netifd/main.c 
netifd_start_process()->
if ((pid = fork()) < 0)
goto error;

fork fail because

log

netifd_start_process>>>>>>>>after fork create
error on triggering 12: Cannot allocate memory

(netifd heap use more and more memories with the script running)


part of the script

uci set wireless.@wifi-iface[$1].mode="$apmode"
uci commit wireless

/sbin/wifi reload

Ryan Hao
  • 11
  • 3
  • There seems to be a problem in your script. Does it have debugging output? Are you properly handling errors from commands you call? How about showing the relevant parts of the code? – Roland Weber Dec 03 '18 at 09:44
  • the script is just change the file etc/config/wirless and commit it to restart hostapd. – Ryan Hao Dec 03 '18 at 09:56
  • Thank you for your comment, and I've updated the question! – Ryan Hao Dec 03 '18 at 10:08

0 Answers0