extern const char *ast_inet_ntoa(char *buf, int bufsiz, struct in_addr ia);
extern int ast_utils_init(void);
+extern int ast_wait_for_input(int fd, int ms);
/* The realloca lets us ast_restrdupa(), but you can't mix any other ast_strdup calls! */
while (moh) {
if (moh->pid) {
ast_log(LOG_DEBUG, "killing %d!\n", moh->pid);
- stime = time(NULL) + 5;
+ stime = time(NULL) + 2;
pid = moh->pid;
moh->pid = 0;
kill(pid, SIGKILL);
- while ((bytes = read(moh->srcfd, buff, 8192)) && time(NULL) < stime) {
+ while ((ast_wait_for_input(moh->srcfd, 100) > -1) && (bytes = read(moh->srcfd, buff, 8192)) && time(NULL) < stime) {
tbytes = tbytes + bytes;
}
ast_log(LOG_DEBUG, "mpg123 pid %d and child died after %d bytes read\n", pid, tbytes);
#include <arpa/inet.h>
#include <asterisk/lock.h>
#include <asterisk/utils.h>
+#include <asterisk/io.h>
#include <asterisk/logger.h>
#include <asterisk/md5.h>
return pthread_create(thread, attr, start_routine, data); /* We're in ast_pthread_create, so it's okay */
}
+int ast_wait_for_input(int fd, int ms)
+{
+ struct pollfd pfd[1];
+ memset(pfd, 0, sizeof(pfd));
+ pfd[0].fd = fd;
+ pfd[0].events = POLLIN|POLLPRI;
+ return poll(pfd, 1, ms);
+}
+
/* Case-insensitive substring matching */
#ifndef LINUX
static char *upper(const char *orig, char *buf, int bufsize)