jerimiah797
02-20-2013, 10:46 AM
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
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