I get the following warning in my asterisk/messages log file:
manager.c: HTTP Manager, fdopen failed: Bad file descriptor!
Using GDB I managed to trace this to manager.c, line 5590, as a result of a failure on line 5588. The appropriate code snippet:
s.session = session;
s.fd = mkstemp(template); /* create a temporary file for command output */
if (s.fd <= -1)
s.f = fdopen(s.fd, "w+");
Honestly, I cannot see how that should fail, and I've had others look at it as well. It makes no sense.
When compiling with DONT_OPTIMIZE this seems to go away, so instead simply compiled with -ggdb. I can reproduce this by logging in via the HTTP interface and then cycling between two commands:
99% of the time it dies on the SIPPeers one, but sometimes on reload too.
I've got some php code that loops using curl and a cookie jar. Only a single http request at a time.
[Edit: Matt Jordan]
The apparent solution was provided by Rosen:
I was digging into this problem for a couple of days.
I did manage to get rid of that error message:
[Oct 2 11:24:16] WARNING manager.c: HTTP Manager, fdopen failed: Bad file descriptor!
The problem was solved for us, by removing
manager.c Revision: 331315
on line 5510
"The fdopen() function associates a stream with the existing file descriptor, fildes. The mode of the stream must be compatible with the mode of the file descriptor. When the stream is closed via fclose(3), fildes is closed also."