diff options
author | Luis Ontanon <luis.ontanon@gmail.com> | 2013-06-25 17:43:52 +0000 |
---|---|---|
committer | Luis Ontanon <luis.ontanon@gmail.com> | 2013-06-25 17:43:52 +0000 |
commit | e200f6cbf9f53a7ea7e4cb3294392d749eb89432 (patch) | |
tree | 72578481cebdff4306311b2a5bb0d73202ac2e9b /echld | |
parent | ce088c334d7dd137aee56095ea2ed89aca67f4f0 (diff) |
This should get cmake to ignore echld...
svn path=/trunk/; revision=50141
Diffstat (limited to 'echld')
-rw-r--r-- | echld/CMakeLists.txt | 80 | ||||
-rw-r--r-- | echld/echld_parent.c | 89 |
2 files changed, 132 insertions, 37 deletions
diff --git a/echld/CMakeLists.txt b/echld/CMakeLists.txt new file mode 100644 index 0000000000..748e8dae8c --- /dev/null +++ b/echld/CMakeLists.txt @@ -0,0 +1,80 @@ +# CMakeLists.txt +# +# $Id$ +# +# Wireshark - Network traffic analyzer +# By Gerald Combs <gerald@wireshark.org> +# Copyright 1998 Gerald Combs +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +set(ECHLD_FILES + echld_common.c + echld_child.c + echld_dispatcher.c + echld_parent.c + echld_util.c +) + +set(wsutil_LIBS + ${GLIB2_LIBRARIES} +) + +add_library(echld ${LINK_MODE_LIB} + ${ECHLD_FILES} +) + +set(FULL_SO_VERSION "0.0.0") + +set_target_properties(wsutil PROPERTIES COMPILE_DEFINITIONS "WS_BUILD_DLL") +set_target_properties(wsutil PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}") +set_target_properties(wsutil PROPERTIES VERSION ${FULL_SO_VERSION} SOVERSION 0) + +# discover and substitute list of include directories for ABI compatibility +# checks +#get_directory_property(INCLUDE_DIRS INCLUDE_DIRECTORIES) +#list(REMOVE_DUPLICATES INCLUDE_DIRS) +#string(REGEX REPLACE ";" "\n" INCLUDE_DIRS "${INCLUDE_DIRS}") +#configure_file(../abi-descriptor.template abi-descriptor.xml) + +# ABI compliance checker can be obtained from +# http://ispras.linux-foundation.org/index.php/ABI_compliance_checker +# Checked using version 1.21.12 +#file(GLOB HEADERS *.h) +#file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/abi-check-headers) +# +#file(COPY ${HEADERS} ../ws_symbol_export.h DESTINATION abi-check-headers) + +#add_custom_command(OUTPUT libwsutil.abi.tar.gz +# COMMAND cp ../config.h abi-check-headers/ +# COMMAND abi-compliance-checker -l libwsutil -v1 ${FULL_SO_VERSION} +# -relpath ${CMAKE_CURRENT_BINARY_DIR} -dump-abi abi-descriptor.xml +# || cat logs/libwsutil/[0-9]*/log.txt +# COMMAND cp abi_dumps/libwsutil/libwsutil_* libwsutil.abi.tar.gz +# COMMAND rm -rf abi-check-headers/* abi_dumps +# DEPENDS ${HEADERS} wsutil) +#add_custom_target(dumpabi-libwsutil DEPENDS libwsutil.abi.tar.gz) + +target_link_libraries(echld ${echld_LIBS}) + +if(NOT ${ENABLE_STATIC}) + install(TARGETS echld + LIBRARY DESTINATION lib + RUNTIME DESTINATION lib + ARCHIVE DESTINATION lib + ) +endif() + diff --git a/echld/echld_parent.c b/echld/echld_parent.c index 466120f46a..e74125abf3 100644 --- a/echld/echld_parent.c +++ b/echld/echld_parent.c @@ -69,9 +69,6 @@ struct _echld_parent { #define PARENT_SEND(BYTEARR,CHILDNUM,TYPE) echld_write_frame(parent.dispatcher_fd, BYTEARR, CHILDNUM, TYPE, parent.reqh_id++, NULL) - -#define PARENT_FATAL(attrs) parent_fatal attrs - #ifdef DEBUG_PARENT static int dbg_level = 0; @@ -83,10 +80,11 @@ static void parent_dbg(int level, const char* fmt, ...) { if (level > dbg_level) return; va_start(ap,fmt); - g_snprintf(str,1024,fmt,ap); + g_vsnprintf(str,1024,fmt,ap); va_end(ap); fprintf(stderr,"ParentDebug: level=%d msg='%s'\n",level,str); + fflush(stderr); } #define PARENT_DBG(attrs) parent_dbg attrs @@ -96,21 +94,25 @@ static void parent_dbg(int level, const char* fmt, ...) { #endif extern void echld_set_parent_dbg_level(int lvl) { - PARENT_DBG((0,"Debug Level Set: %d",(dbg_level = lvl))); + (dbg_level = lvl); + PARENT_DBG((0,"Debug Level Set: %d",lvl)); } + +#define PARENT_FATAL(attrs) parent_fatal attrs + static void parent_fatal(int exit_code, const char* fmt, ...) { va_list ap; char str[1024]; va_start(ap,fmt); - g_snprintf(str,1024,fmt,ap); + g_vsnprintf(str,1024,fmt,ap); va_end(ap); #ifdef DEBUG_PARENT - PARENT_DBG((0,"Fatal error: %s",str)); + PARENT_DBG((0,"Fatal error: exit_code=%d str=%s",exit_code,str)); #else - fprintf(stderr,"Fatal error: %s",str); + fprintf(stderr,"Fatal error: exit_code=%d str=%s",exit_code,str); #endif exit(exit_code); @@ -184,6 +186,8 @@ void echld_initialize(echld_encoding_t enc) { int from_disp[2]; int to_disp[2]; + PARENT_DBG((1,"Echld Starting")); + if (enc != ECHLD_ENCODING_JSON) { PARENT_FATAL((1111,"Only JSON implemented")); } @@ -195,45 +199,56 @@ void echld_initialize(echld_encoding_t enc) { } else { int pid; int i; - if (( pid = fork() < 0)) { + + pid = fork(); + + if ( pid < 0 ) { PARENT_FATAL((1114,"Failed to fork() reason='%s'",strerror(errno))); } else if ( pid == 0) { #ifdef PARENT_THREADS reader_realloc_buf = child_realloc_buff; #endif + + PARENT_DBG((1,"Dispatcher starting")); /* child code */ - echld_cleanup(); + //echld_cleanup(); + PARENT_DBG((2,"Dispatcher starting..")); - echld_dispatcher_start(to_disp,from_disp); + //echld_dispatcher_start(to_disp,from_disp); PARENT_FATAL((1115,"This shoudln't happen")); + } else { + /* parent code */ + #ifdef PARENT_THREADS + reader_realloc_buf = parent_realloc_buff; + #endif + + PARENT_DBG((3,"Dispatcher forked")); + + echld_get_all_codecs(NULL, NULL, &parent.enc, &parent.dec); + parent.children = g_new0(echld_t,ECHLD_MAX_CHILDREN); + parent.snd = g_byte_array_new(); + parent.dispatcher_fd = to_disp[0]; + + echld_init_reader(&(parent.reader),from_disp[1],4096); + + parent.children[0].chld_id = 0; + parent.children[0].data = NULL; + parent.children[0].state = IDLE; + parent.children[0].handlers = g_array_new(TRUE,TRUE,sizeof(hdlr_t)); + + for (i=1;i<ECHLD_MAX_CHILDREN;i++) { + parent.children[i].chld_id = -1; + parent.children[i].data = NULL; + parent.children[i].state = FREE; + parent.children[i].handlers = g_array_new(TRUE,TRUE,sizeof(hdlr_t)); + } + + signal(SIGCHLD,parent_reaper); + close(to_disp[1]); + close(from_disp[0]); + PARENT_DBG((3,"Ready")); } - - /* parent code */ -#ifdef PARENT_THREADS - reader_realloc_buf = parent_realloc_buff; -#endif - - PARENT_DBG((3,"Dispatcher forked")); - - echld_get_all_codecs(NULL, NULL, &parent.enc, &parent.dec); - parent.children = g_new0(echld_t,ECHLD_MAX_CHILDREN); - parent.snd = g_byte_array_new(); - parent.dispatcher_fd = to_disp[0]; - - echld_init_reader(&(parent.reader),from_disp[1],4096); - - for (i=0;i<ECHLD_MAX_CHILDREN;i++) { - parent.children[i].chld_id = -1; - parent.children[i].data = NULL; - parent.children[i].state = FREE; - parent.children[i].handlers = g_array_new(TRUE,TRUE,sizeof(hdlr_t)); - } - - signal(SIGCHLD,parent_reaper); - close(to_disp[1]); - close(from_disp[0]); - PARENT_DBG((3,"Ready")); } } |