mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-03 20:46:28 +00:00
fix hung linphonec when using pipes
git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@486 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
This commit is contained in:
parent
3f84c8d408
commit
2ac9872ae1
5 changed files with 22 additions and 10 deletions
|
|
@ -409,7 +409,7 @@ lpc_cmd_autoanswer(LinphoneCore *lc, char *args)
|
|||
static int
|
||||
lpc_cmd_quit(LinphoneCore *lc, char *args)
|
||||
{
|
||||
linphonec_finish(EXIT_SUCCESS);
|
||||
linphonec_main_loop_exit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ static bool_t display_enabled=FALSE;
|
|||
static bool_t preview_enabled=FALSE;
|
||||
static bool_t show_general_state=FALSE;
|
||||
static bool_t unix_socket=FALSE;
|
||||
static bool_t linphonec_running=TRUE;
|
||||
LPC_AUTH_STACK auth_stack;
|
||||
static int trace_level = 0;
|
||||
static char *logfile_name = NULL;
|
||||
|
|
@ -424,7 +425,7 @@ static void *pipe_thread(void*p){
|
|||
if (pipe_reader_run) fprintf(stderr,"accept() failed: %s\n",strerror(errno));
|
||||
}
|
||||
}
|
||||
printf("Exiting pipe_reader_thread.");
|
||||
ms_message("Exiting pipe_reader_thread.");
|
||||
fflush(stdout);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -437,6 +438,7 @@ static void start_pipe_reader(void){
|
|||
|
||||
static void stop_pipe_reader(void){
|
||||
pipe_reader_run=FALSE;
|
||||
linphonec_command_finished();
|
||||
ortp_server_pipe_close(server_sock);
|
||||
ortp_thread_join(pipe_reader_th,NULL);
|
||||
}
|
||||
|
|
@ -627,6 +629,10 @@ linphonec_init(int argc, char **argv)
|
|||
}
|
||||
|
||||
|
||||
void linphonec_main_loop_exit(void){
|
||||
linphonec_running=FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Close linphonec, cleanly terminating
|
||||
* any pending call
|
||||
|
|
@ -635,9 +641,10 @@ void
|
|||
linphonec_finish(int exit_status)
|
||||
{
|
||||
printf("Terminating...\n");
|
||||
|
||||
|
||||
/* Terminate any pending call */
|
||||
linphonec_parse_command_line(&linphonec, "terminate");
|
||||
linphonec_command_finished();
|
||||
#ifdef HAVE_READLINE
|
||||
linphonec_finish_readline();
|
||||
#endif
|
||||
|
|
@ -875,7 +882,6 @@ static int
|
|||
linphonec_main_loop (LinphoneCore * opm, char * sipAddr)
|
||||
{
|
||||
char buf[LINE_MAX_LEN]; /* auto call handling */
|
||||
bool_t run=TRUE;
|
||||
char *input;
|
||||
|
||||
print_prompt(opm);
|
||||
|
|
@ -885,10 +891,10 @@ linphonec_main_loop (LinphoneCore * opm, char * sipAddr)
|
|||
if (sipAddr != NULL )
|
||||
{
|
||||
snprintf (buf, sizeof(buf),"call %s", sipAddr);
|
||||
run=linphonec_parse_command_line(&linphonec, buf);
|
||||
linphonec_parse_command_line(&linphonec, buf);
|
||||
}
|
||||
|
||||
while ((input=linphonec_readline(prompt)))
|
||||
while (linphonec_running && (input=linphonec_readline(prompt)))
|
||||
{
|
||||
char *iptr; /* input and input pointer */
|
||||
size_t input_len;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ Includes=../oRTP/include;../mediastreamer2/include;../../linphone-deps/include;.
|
|||
Libs=../oRTP/build/win32native;../mediastreamer2/build/win32native;../coreapi/;../../linphone-deps/lib
|
||||
ResourceIncludes=
|
||||
MakeIncludes=
|
||||
Compiler=-g -02_@@_-DIN_LINPHONE_@@_-D_WIN32_WINNT=0x0501 _@@_-Wall -Werror_@@_
|
||||
Compiler=-ggdb -O2_@@_-DIN_LINPHONE_@@_-D_WIN32_WINNT=0x0501 _@@_-Wall _@@_
|
||||
CppCompiler=
|
||||
Linker=-mwindows_@@_-Wl,--export-all-symbols_@@_-Wl,--add-stdcall-alias_@@_-llinphone_@@_-lmediastreamer2_@@_-lortp_@@_-losip2_@@_-losipparser2_@@_-leXosip2_@@_-lws2_32_@@_
|
||||
PreprocDefines=
|
||||
|
|
|
|||
|
|
@ -104,10 +104,12 @@ typedef struct {
|
|||
|
||||
extern int linphonec_parse_command_line(LinphoneCore *lc, char *cl);
|
||||
extern char *linphonec_command_generator(const char *text, int state);
|
||||
void linphonec_main_loop_exit();
|
||||
extern void linphonec_finish(int exit_status);
|
||||
extern char *linphonec_readline(char *prompt);
|
||||
void linphonec_set_autoanswer(bool_t enabled);
|
||||
bool_t linphonec_get_autoanswer();
|
||||
void linphonec_command_finished(void);
|
||||
|
||||
|
||||
#endif /* def LINPHONEC_H */
|
||||
|
|
|
|||
|
|
@ -435,14 +435,18 @@ ortp_server_pipe_close() makes this function to exit.
|
|||
ortp_pipe_t ortp_server_pipe_accept_client(ortp_pipe_t server){
|
||||
OVERLAPPED ol;
|
||||
DWORD undef;
|
||||
HANDLE handles[2];
|
||||
memset(&ol,0,sizeof(ol));
|
||||
ol.hEvent=event;
|
||||
ResetEvent(event);
|
||||
ol.hEvent=CreateEvent(NULL,TRUE,FALSE,NULL);
|
||||
ConnectNamedPipe(server,&ol);
|
||||
WaitForSingleObject(ol.hEvent,INFINITE);
|
||||
handles[0]=ol.hEvent;
|
||||
handles[1]=event;
|
||||
WaitForMultipleObjects(2,handles,FALSE,INFINITE);
|
||||
if (GetOverlappedResult(server,&ol,&undef,FALSE)){
|
||||
CloseHandle(ol.hEvent);
|
||||
return server;
|
||||
}
|
||||
CloseHandle(ol.hEvent);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue