troglobit / uftpd

FTP/TFTP server for Linux that just works™
https://troglobit.com/projects/uftpd/
ISC License
182 stars 32 forks source link

High CPU usage #9

Closed oz123 closed 6 years ago

oz123 commented 7 years ago

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

troglobit commented 7 years ago

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
troglobit commented 7 years ago

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

Thanks for the bug report! :smiley:

oz123 commented 6 years ago

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.

troglobit commented 6 years ago

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

oz123 commented 6 years ago

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.

troglobit commented 6 years ago

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

troglobit commented 6 years ago

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 6 years ago

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.

troglobit commented 6 years ago

Oz, I've made two fixes to uftpd:

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

troglobit commented 6 years ago

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

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

oz123 commented 6 years ago

@troglobit awesome! I will also test it soon.

troglobit commented 6 years ago

@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 6 years ago

@troglobit I am glad I could help as tester!

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

troglobit commented 6 years ago

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" :)