forked from Mirrors/freeswitch
fix
This commit is contained in:
parent
0f6a2bf863
commit
239094e49c
@ -2538,68 +2538,6 @@ SWITCH_DECLARE(int) switch_stream_system_fork(const char *cmd, switch_stream_han
|
||||
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
#ifndef WIN32
|
||||
static int switch_stream_system_thread(const char *cmd, switch_stream_handle_t *stream)
|
||||
{
|
||||
#ifdef WIN32
|
||||
return switch_system(cmd, SWITCH_TRUE);
|
||||
#else
|
||||
switch_thread_t *thread;
|
||||
switch_threadattr_t *thd_attr;
|
||||
int ret = 0;
|
||||
struct system_thread_handle *sth;
|
||||
switch_memory_pool_t *pool;
|
||||
int fds[2] = {0};
|
||||
char buf[1024] = "";
|
||||
int bytes;
|
||||
|
||||
if (pipe(fds)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pipe Failure\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(sth = switch_core_alloc(pool, sizeof(struct system_thread_handle)))) {
|
||||
switch_core_destroy_memory_pool(&pool);
|
||||
return 1;
|
||||
}
|
||||
|
||||
sth->pool = pool;
|
||||
sth->cmd = switch_core_strdup(pool, cmd);
|
||||
sth->fds = fds;
|
||||
|
||||
switch_thread_cond_create(&sth->cond, sth->pool);
|
||||
switch_mutex_init(&sth->mutex, SWITCH_MUTEX_NESTED, sth->pool);
|
||||
switch_mutex_lock(sth->mutex);
|
||||
|
||||
switch_threadattr_create(&thd_attr, sth->pool);
|
||||
switch_threadattr_stacksize_set(thd_attr, SWITCH_SYSTEM_THREAD_STACKSIZE);
|
||||
switch_threadattr_detach_set(thd_attr, 1);
|
||||
switch_thread_create(&thread, thd_attr, system_thread, sth, sth->pool);
|
||||
|
||||
close(fds[1]);
|
||||
while ((bytes = read(fds[0], buf, sizeof(buf))) > 0) {
|
||||
stream->raw_write_function(stream, (unsigned char *)buf, bytes);
|
||||
}
|
||||
close(fds[0]);
|
||||
switch_thread_cond_wait(sth->cond, sth->mutex);
|
||||
ret = sth->ret;
|
||||
switch_mutex_unlock(sth->mutex);
|
||||
|
||||
return ret;
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
=======
|
||||
>>>>>>> the threaded one seems to not work using only fork
|
||||
SWITCH_DECLARE(int) switch_stream_system(const char *cmd, switch_stream_handle_t *stream)
|
||||
{
|
||||
#ifdef WIN32
|
||||
|
Loading…
Reference in New Issue
Block a user