troglobit/uftpd

High CPU usage

oz123 opened this issue ยท 14 comments

oz123 commented

I compiled the latest version of uftpd with all the latest requirements from latest git sources.
The resulting binary consume 100% after accepting files.

Well that's not right! ;-)

I just pushed an update, new libuEv version released, which possibly fixes your issue. I tested it very quickly on my system and it seemed stable from a first glance:

./uftpd -n -o ftp=2121,tftp=0 /path/to/ftp/home

Yup, that must've been it. Was a regression in the handling of EPOLLHUP in the library. Closing.

Thanks for the bug report! ๐Ÿ˜ƒ

oz123 commented

This still hits me on Gentoo, even with dev-libs/libuev-2.1.2.

I am trying to connect from VLC android , which triggers this high cpu usage, after disconnecting.

OK. I'll have a look at it. Do you know of any other way to reproduce the problem?

oz123 commented

Unfortunately, no. I also tested other FTP clients on Android, and they don't trigger this behaviour.
I believe It's specifically something that this FTP client which is built in VLC.
Oddly enough, this FTP client does not trigger this behaviour with other FTP servers.

I'll see what I can do. Thanks for reporting it!

Update: spent the last couple of days trying to reproduce the bug. So far I've managed to reproduce 100% CPU load once, but I've never managed to get the VLC app to get a proper FTP listing? I've enabled debug logs and even run wireshark to see the actual transaction, yet so far no luck tracking down the culprit.

oz123 commented

Yes. I think there is bug in VLC. It doesn't list properly. I think the way to reproduce the CPU spikes, is by not closing the connection properly.

I wish I could be more helpful here. I did not find a way to make uftpd become really verbose.

Oz, I've made two fixes to uftpd:

  • Invalid line endings for NLST command, should be \r\n but was \n
  • High CPU usage due to event loop callback getting stuck waiting for child process

However, neither of them fixes the issue with the VLC app. I believe uftpd triggers a compatibility mode in the app since uftpd does not (yet) support RFC 2428 EPSV and EPRT commands. I've opened #11 to track that issue separately, since I hope the last of the 100% CPU bugs have been fixed as of cec7f50

So, I found the root cause for the VLC problems:

  • EPSV was missing (as mentioned above), not critical
  • MLSD was missing (new LIST/NLST command), with it missing VLC defaulted to use NLST which seems buggy in VLC.

In #11 and #12 I've added basic support for these commands and the VLC app now works for me :-)

oz123 commented

@troglobit awesome! I will also test it soon.

@oz123 I have to point out that by "works for me", it can now list files properly. Unfortunately uftpd in its current state is incapable of streaming to VLC. There are several commands and functionality missing; REST (restart at file offset), ABOR (abort/pause current transaction), as well as large-file support in RETR (retrieve file).

Sorry about that :-(

I'm filing several separate issues now to track the things I've found so far. That VLC app. turned out to be a great test case for my little FTP server :-)

oz123 commented

@troglobit I am glad I could help as tester!

I really appreciate your work and communication. No need to appologize.

There, finally ... lots of tiny details, but now it finally works to stream using the VLC Android app. As of ce1c923 it "works for me" :)