diff --git a/linphone/console/commands.c b/linphone/console/commands.c index f301c434d7222fed932236e202bd0d82e9ccbe7e..199652144cf24b00be8f1e2e21f20e1aea930417 100644 --- a/linphone/console/commands.c +++ b/linphone/console/commands.c @@ -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; } diff --git a/linphone/console/linphonec.c b/linphone/console/linphonec.c index 7baa1fdcbd3bb935a1dd3d689b0e07e48ed646c6..153518ff5dd72e3a36046209205c1bda7049a4b9 100644 --- a/linphone/console/linphonec.c +++ b/linphone/console/linphonec.c @@ -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; diff --git a/linphone/console/linphonec.dev b/linphone/console/linphonec.dev index 3e824e6693fb4a72926c34428d736eefc0fb6573..bbdc57e1cb6d224eb08e57d325ff00a1f9e6a277 100755 --- a/linphone/console/linphonec.dev +++ b/linphone/console/linphonec.dev @@ -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= diff --git a/linphone/console/linphonec.h b/linphone/console/linphonec.h index c69877b4055b4ea4da01d8950d79745e4e166b0e..59306572c312df66932e27199093432a585b19b1 100644 --- a/linphone/console/linphonec.h +++ b/linphone/console/linphonec.h @@ -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 */ diff --git a/linphone/oRTP/src/port.c b/linphone/oRTP/src/port.c index 02a8e14e9248b13fee2fe697d23bb915f133593e..4171aed03e45e7835e24e59f4c95d4af6c4816b9 100644 --- a/linphone/oRTP/src/port.c +++ b/linphone/oRTP/src/port.c @@ -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; }