Audio/video stream recording forums

Attention Visitor:
You may have to register or log in before you can post:
  • Click the register link to sign up.
  • Registered members please fill in the form below and click the "Log in" button.
To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Audio/video stream recording forums > Streaming media recording forum > rtmpdump
Register FAQ Members List Calendar Mark Forums Read

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-20-2013, 11:46 AM
jerimiah797 jerimiah797 is offline
Junior Member
 
Join Date: Feb 2013
Posts: 2
jerimiah797 is on a distinguished road
Default

rtmpgw is spiking the processor when run in background - solved


Hi everyone. I don't know how many people have seen this problem, but I figured out a solution so I thought I would share it.

Problem: when invoking rtmpgw from the shell with nohup to detach it from the shell and let it run as a daemon in the background, the process would jump to 100% cpu even though it was just sitting there waiting for further commands.

nohup rtmpgw -g 8902 > rtmplog.txt 2>&1 & exit

The log that nohup produced after just a few seconds was tens of thousands of lines of repeating text like this:

HTTP-RTMP Stream Gateway v2.4
(c) 2010 Andrej Stepanchuk, Howard Chu; license: GPL

Streaming on http://0.0.0.0:8902
Unknown command '<FF>', ignoring
Unknown command '<FF>', ignoring
Unknown command '<FF>', ignoring
Unknown command '<FF>', ignoring
Unknown command '<FF>', ignoring
Unknown command '<FF>', ignoring
Unknown command '<FF>', ignoring
Unknown command '<FF>', ignoring
Unknown command '<FF>', ignoring
Unknown command '<FF>', ignoring
Unknown command '<FF>', ignoring
Unknown command '<FF>', ignoring

I tracked this down to a bug in the source code that gets confused when stdin is closed, and reacts as if the computer is continually typing the EOF character, generating the above error message.

This can be worked around by deleting most of the code in the area where keyboard input is processed. The only thing this part of the code does is listen for the letter 'q', to quit the server. It returns an error for anything else. Since it is just as easy to hit Ctrl-C as it is to hit q to quit the server, this code is really unnecessary. It starts on line 272 of rtmpgw.c

controlServerThread(void *unused)
{
/*
char ich;
while (1)
{
ich = getchar();
switch (ich)
{
case 'q':
RTMP_LogPrintf("Exiting\n");
stopStreaming(httpServer);
exit(0);
break;
default:
//RTMP_LogPrintf("Unknown command \'%c\', ignoring\n", ich);
break;
}
}
*/
TFRET();
}

I simply inserted C-language comment codes to comment out the whole code block. Then recompile, and everything works as expected.

If any of the devs see this, they may want to consider adding a command line switch to shut this part of the code down when you want to run rtmpgw as a detached background process or daemon.

Hope this helps.

-jerimiah797

Last edited by jerimiah797 : 02-20-2013 at 11:54 AM. Reason: fix typos
Reply With Quote
 
Tags: ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -6. The time now is 10:46 PM.


Powered by All-streaming-media.com; 2006-2011
vB forum hacked with Zoints add-ons