From a3165ad7d58d0d2e8f559eb4df14dcd2d59966f8 Mon Sep 17 00:00:00 2001 From: Auxten Date: Wed, 9 May 2012 11:35:32 +0800 Subject: [PATCH] move to company svn --- example/client.cpp | 14 ++++++ src/Makefile.am | 2 +- src/Makefile.in | 31 +++++++----- src/aclocal.m4 | 15 +++--- src/async_clnt.cpp | 110 +++++++++++++++++++++++++++++++++++++++--- src/async_clnt.h | 26 ++++++++++ src/async_pool.h | 3 +- src/async_threads.cpp | 6 +++ src/aysnc_clnt.h | 14 ------ src/configure | 8 +-- src/gingko.h | 27 +++++++---- src/hash/Makefile.in | 8 +-- src/hash/aclocal.m4 | 15 +++--- src/hash/configure | 8 +-- src/missing | 53 ++------------------ src/socket.cpp | 64 ------------------------ 16 files changed, 222 insertions(+), 182 deletions(-) create mode 100644 src/async_clnt.h delete mode 100644 src/aysnc_clnt.h diff --git a/example/client.cpp b/example/client.cpp index fe7176b..c79d6cc 100644 --- a/example/client.cpp +++ b/example/client.cpp @@ -6,6 +6,7 @@ */ #include "gko.h" +#include "async_clnt.h" /// gingko global stuff s_gingko_global_t gko; @@ -36,7 +37,10 @@ int main(int argc, char** argv) pthread_attr_t g_attr; pthread_t vnode_pthread[T_NUM]; void *status; + unsigned short proto_ver; + unsigned int msg_len; + /* if (pthread_attr_init(&g_attr) != 0) { gko_log(FATAL, FLF("pthread_mutex_destroy error")); @@ -70,6 +74,16 @@ int main(int argc, char** argv) return -1; } } + */ + char buf[20] = {'\0'}; + fill_cmd_head(buf, INT32_MAX); + parse_cmd_head(buf, &proto_ver, &msg_len); + gko_log(DEBUG, "%s %d", buf, msg_len); + std::vector conn_vec; + std::vector srv_vec(1000, server); + connect_hosts(srv_vec, &conn_vec); + sleep(10); + disconnect_hosts(conn_vec); return 0; } diff --git a/src/Makefile.am b/src/Makefile.am index 9b045c6..039a0e3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,6 +11,6 @@ export INCLUDES noinst_LIBRARIES=libgko.a DEFS+=-O0 -D_GNU_SOURCE -ggdb -funsigned-char -libgko_a_SOURCES=async_threads.cpp async_conn.cpp \ +libgko_a_SOURCES=async_threads.cpp async_conn.cpp async_clnt.cpp \ gingko_base.cpp log.cpp socket.cpp limit.cpp libgko_a_LDFLAGS=-O0 -D_GNU_SOURCE -ggdb -funsigned-char \ No newline at end of file diff --git a/src/Makefile.in b/src/Makefile.in index 3895ae6..184438b 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11.2 from Makefile.am. +# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -36,7 +36,7 @@ subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ - depcomp install-sh missing + TODO depcomp install-sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -53,8 +53,8 @@ ARFLAGS = cru libgko_a_AR = $(AR) $(ARFLAGS) libgko_a_LIBADD = am_libgko_a_OBJECTS = async_threads.$(OBJEXT) async_conn.$(OBJEXT) \ - gingko_base.$(OBJEXT) log.$(OBJEXT) socket.$(OBJEXT) \ - limit.$(OBJEXT) + async_clnt.$(OBJEXT) gingko_base.$(OBJEXT) log.$(OBJEXT) \ + socket.$(OBJEXT) limit.$(OBJEXT) libgko_a_OBJECTS = $(am_libgko_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp @@ -86,9 +86,11 @@ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ - { test ! -d "$(distdir)" \ - || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ - && rm -fr "$(distdir)"; }; } + if test -d "$(distdir)"; then \ + find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -rf "$(distdir)" \ + || { sleep 5 && rm -rf "$(distdir)"; }; \ + else :; fi am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ @@ -222,7 +224,7 @@ INCLUDES = -I$(srcdir)/src\ #noinst_PROGRAMS=gingko_serv gingko_clnt serv_unittest clnt_unittest noinst_LIBRARIES = libgko.a -libgko_a_SOURCES = async_threads.cpp async_conn.cpp \ +libgko_a_SOURCES = async_threads.cpp async_conn.cpp async_clnt.cpp \ gingko_base.cpp log.cpp socket.cpp limit.cpp libgko_a_LDFLAGS = -O0 -D_GNU_SOURCE -ggdb -funsigned-char @@ -283,7 +285,7 @@ distclean-hdr: clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) -libgko.a: $(libgko_a_OBJECTS) $(libgko_a_DEPENDENCIES) +libgko.a: $(libgko_a_OBJECTS) $(libgko_a_DEPENDENCIES) $(EXTRA_libgko_a_DEPENDENCIES) -rm -f libgko.a $(libgko_a_AR) libgko.a $(libgko_a_OBJECTS) $(libgko_a_LIBADD) $(RANLIB) libgko.a @@ -294,6 +296,7 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/async_clnt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/async_conn.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/async_threads.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gingko_base.Po@am__quote@ @@ -525,6 +528,10 @@ dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__remove_distdir) +dist-lzip: distdir + tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz + $(am__remove_distdir) + dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) @@ -561,6 +568,8 @@ distcheck: dist bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ + *.tar.lz*) \ + lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ @@ -747,8 +756,8 @@ uninstall-am: .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-generic \ clean-noinstLIBRARIES ctags ctags-recursive dist dist-all \ - dist-bzip2 dist-gzip dist-lzma dist-shar dist-tarZ dist-xz \ - dist-zip distcheck distclean distclean-compile \ + dist-bzip2 dist-gzip dist-lzip dist-lzma dist-shar dist-tarZ \ + dist-xz dist-zip distcheck distclean distclean-compile \ distclean-generic distclean-hdr distclean-tags distcleancheck \ distdir distuninstallcheck dvi dvi-am html html-am info \ info-am install install-am install-data install-data-am \ diff --git a/src/aclocal.m4 b/src/aclocal.m4 index 87a1009..59aa29e 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -1,4 +1,4 @@ -# generated automatically by aclocal 1.11.2 -*- Autoconf -*- +# generated automatically by aclocal 1.11.3 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, @@ -38,7 +38,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.11.2], [], +m4_if([$1], [1.11.3], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -54,7 +54,7 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.11.2])dnl +[AM_AUTOMAKE_VERSION([1.11.3])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) @@ -886,7 +886,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -908,10 +908,11 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. -AM_MISSING_PROG([AMTAR], [tar]) +[# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AC_SUBST([AMTAR], ['$${TAR-tar}']) m4_if([$1], [v7], - [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) diff --git a/src/async_clnt.cpp b/src/async_clnt.cpp index f4fecf4..c0c4c29 100644 --- a/src/async_clnt.cpp +++ b/src/async_clnt.cpp @@ -5,14 +5,92 @@ * Author: auxten */ +#include +#include +#include +#include + +#include "config.h" +#include "gingko.h" +#include "log.h" +#include "socket.h" +#ifdef __APPLE__ +#include +#else +#include +#endif /** __APPLE__ **/ + #include "async_pool.h" #include "socket.h" +/** + * @brief non-blocking version connect + * + * @see + * @note + * @author auxten + * @date Apr 22, 2012 + **/ +int nb_connect(const s_host_t * h, struct conn_client* conn) +{ + int sock = -1; + int ret = -1; + struct sockaddr_in channel; + in_addr_t host; + int addr_len; + + addr_len = getaddr_my(h->addr, &host); + if (FAIL_CHECK(!addr_len)) + { + gko_log(WARNING, "gethostbyname %s error", h->addr); + ret = -1; + goto NB_CONNECT_END; + } + conn->client_addr = host; + sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); + if (FAIL_CHECK(sock < 0)) + { + gko_log(WARNING, "get socket error"); + ret = -1; + goto NB_CONNECT_END; + } + + memset(&channel, 0, sizeof(channel)); + channel.sin_family = AF_INET; + memcpy(&channel.sin_addr.s_addr, &host, addr_len); + channel.sin_port = htons(h->port); + + /** set the connect non-blocking then blocking for add timeout on connect **/ + if (FAIL_CHECK(setnonblock(sock) < 0)) + { + gko_log(WARNING, "set socket non-blocking error"); + ret = -1; + goto NB_CONNECT_END; + } + + /** connect and send the msg **/ + if (FAIL_CHECK(connect(sock, (struct sockaddr *) &channel, sizeof(channel)) && + errno != EINPROGRESS)) + { + gko_log(WARNING, "connect error"); + ret = HOST_DOWN_FAIL; + goto NB_CONNECT_END; + } + + ret = sock; + + NB_CONNECT_END: + /// + if (ret < 0 && sock >= 0) + { + close_socket(sock); + } + return ret; +} + int connect_hosts(const std::vector & host_vec, std::vector * conn_vec) { - struct conn_client conn; - memset(&conn, 0, sizeof(conn)); int conn_ok = 0; int conn_err = 0; @@ -20,21 +98,27 @@ int connect_hosts(const std::vector & host_vec, { return -1; } + + conn_vec->clear(); + /// perform non-blocking connect - for (std::vector::iterator it = host_vec.begin(); + for (std::vector::const_iterator it = host_vec.begin(); it != host_vec.end(); it++) { int nb_conn_sock; struct conn_client clnt; - clnt.client_addr = it-> - nb_conn_sock = nb_connect(&(*it)); + /// connect and set in_addr_t to clnt->client_addr + nb_conn_sock = nb_connect(&(*it), &clnt); if (nb_conn_sock < 0) { + char ip[18] = {'\0'}; clnt.client_fd = -1; clnt.state = conn_connect_fail; conn_err++; + gko_log(DEBUG, "connect fail for %s:%d failed", + inet_neta(clnt.client_addr, ip, 17), clnt.client_port); } else { @@ -51,12 +135,24 @@ int connect_hosts(const std::vector & host_vec, int disconnect_hosts(std::vector & conn_vec) { - for(std::vector::iterator it = conn_vec.begin(); + for (std::vector::iterator it = conn_vec.begin(); it != conn_vec.end(); it++) { - close(it->client_fd) + if (it->state != conn_closed) + { + char ip[18] = {'\0'}; + if (close(it->client_fd) != 0) + gko_log(DEBUG, "close fd failed for %s:%d", + inet_neta(it->client_addr, ip, 17), it->client_port); + it->state = conn_closed; + } } + return 0; +} + +int fill_request(const char * request, const int req_len, std::vector * conn_vec) +{ return 0; } diff --git a/src/async_clnt.h b/src/async_clnt.h new file mode 100644 index 0000000..02f387e --- /dev/null +++ b/src/async_clnt.h @@ -0,0 +1,26 @@ +/* + * aysnc_clnt.h + * + * Created on: May 4, 2012 + * Author: auxten + */ + +#ifndef AYSNC_CLNT_H_ +#define AYSNC_CLNT_H_ + +/** + * @brief non-blocking version connect + * + * @see + * @note + * @author auxten + * @date Apr 22, 2012 + **/ +int nb_connect(const s_host_t * h, struct conn_client* conn); + +int connect_hosts(const std::vector & host_vec, + std::vector * conn_vec); + +int disconnect_hosts(std::vector & conn_vec); + +#endif /* AYSNC_CLNT_H_ */ diff --git a/src/async_pool.h b/src/async_pool.h index 03c3f85..3606d59 100644 --- a/src/async_pool.h +++ b/src/async_pool.h @@ -59,6 +59,7 @@ enum conn_states { conn_timeout, conn_reseted, conn_connect_fail, + conn_closed, conn_max_state /**< Max state value (used for assertion) */ }; @@ -68,7 +69,7 @@ struct conn_client { int id; int client_fd; - unsigned long client_addr; + in_addr_t client_addr; int client_port; unsigned int conn_time; func_t handle_client; diff --git a/src/async_threads.cpp b/src/async_threads.cpp index c60b5af..0c44c90 100644 --- a/src/async_threads.cpp +++ b/src/async_threads.cpp @@ -600,6 +600,12 @@ void gko_pool::state_machine(conn_client *c) assert(false); break; + default: + gko_log(DEBUG, "state: %d", c->state); + assert(false); + break; + + } } diff --git a/src/aysnc_clnt.h b/src/aysnc_clnt.h deleted file mode 100644 index 3dfdc36..0000000 --- a/src/aysnc_clnt.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * aysnc_clnt.h - * - * Created on: May 4, 2012 - * Author: auxten - */ - -#ifndef AYSNC_CLNT_H_ -#define AYSNC_CLNT_H_ - - - - -#endif /* AYSNC_CLNT_H_ */ diff --git a/src/configure b/src/configure index 08d1b5f..2854ac6 100755 --- a/src/configure +++ b/src/configure @@ -2731,11 +2731,11 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. -# Always define AMTAR for backward compatibility. +# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AMTAR='$${TAR-tar}' -AMTAR=${AMTAR-"${am_missing_run}tar"} - -am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' +am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' diff --git a/src/gingko.h b/src/gingko.h index 9ba9959..29cd624 100644 --- a/src/gingko.h +++ b/src/gingko.h @@ -58,7 +58,7 @@ #define HASH_BYTE_NUM_ONCE 8 #define CMD_PREFIX_BYTE 16 #if CMD_PREFIX_BYTE == 16 -#define PREFIX_CMD " " +#define PREFIX_CMD "0000000000000000" #endif /// cmd keyword len @@ -74,7 +74,7 @@ static GKO_CONST_STR GKO_VERSION = _GKO_VERSION; static GKO_CONST_STR GKO_VERSION = "unknown"; #endif /// protocol version -static const short PROTO_VER = 0; +static const short PROTO_VER = '0'; /// root uid static const uid_t ROOT = 0; /// block size in bytes @@ -739,17 +739,26 @@ static inline int gsendfile(int out_fd, int in_fd, off_t *offset, * @author auxten * @date Jan 10, 2012 **/ -static inline void fill_cmd_head(char * cmd, const int msg_len) +static inline void fill_cmd_head(char * cmd, int msg_len) { - memset(cmd, 0, CMD_PREFIX_BYTE); - *((unsigned short *) cmd) = PROTO_VER; - *((int *) (cmd + CMD_PREFIX_BYTE - sizeof(int))) = - (int) (msg_len - CMD_PREFIX_BYTE); + memset(cmd, '0', CMD_PREFIX_BYTE); + + char * p = cmd + CMD_PREFIX_BYTE - 1; + while (msg_len > 0) + { + *(p--) = (char)(msg_len % 10) + '0'; + msg_len /= 10; + } } static inline void parse_cmd_head(const char * cmd, unsigned short * proto_ver, unsigned int * msg_len) { - *proto_ver = *((unsigned short *) cmd); - *msg_len = *((int *) (cmd + CMD_PREFIX_BYTE - sizeof(int))) + CMD_PREFIX_BYTE; + *proto_ver = 0; + *msg_len = 0; + const char * p = cmd + 1; /// leave 1 byte for proto_ver + while (p - cmd < CMD_PREFIX_BYTE) + { + *msg_len = (*msg_len) * 10 + *(p++) - '0'; + } } #endif /** GINGKO_H_ **/ diff --git a/src/hash/Makefile.in b/src/hash/Makefile.in index 6993149..328febc 100644 --- a/src/hash/Makefile.in +++ b/src/hash/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated by automake 1.11.2 from Makefile.am. +# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, @@ -254,15 +254,15 @@ $(am__aclocal_m4_deps): clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) -libgko_zip.a: $(libgko_zip_a_OBJECTS) $(libgko_zip_a_DEPENDENCIES) +libgko_zip.a: $(libgko_zip_a_OBJECTS) $(libgko_zip_a_DEPENDENCIES) $(EXTRA_libgko_zip_a_DEPENDENCIES) -rm -f libgko_zip.a $(libgko_zip_a_AR) libgko_zip.a $(libgko_zip_a_OBJECTS) $(libgko_zip_a_LIBADD) $(RANLIB) libgko_zip.a -libmd5.a: $(libmd5_a_OBJECTS) $(libmd5_a_DEPENDENCIES) +libmd5.a: $(libmd5_a_OBJECTS) $(libmd5_a_DEPENDENCIES) $(EXTRA_libmd5_a_DEPENDENCIES) -rm -f libmd5.a $(libmd5_a_AR) libmd5.a $(libmd5_a_OBJECTS) $(libmd5_a_LIBADD) $(RANLIB) libmd5.a -libxor_hash.a: $(libxor_hash_a_OBJECTS) $(libxor_hash_a_DEPENDENCIES) +libxor_hash.a: $(libxor_hash_a_OBJECTS) $(libxor_hash_a_DEPENDENCIES) $(EXTRA_libxor_hash_a_DEPENDENCIES) -rm -f libxor_hash.a $(libxor_hash_a_AR) libxor_hash.a $(libxor_hash_a_OBJECTS) $(libxor_hash_a_LIBADD) $(RANLIB) libxor_hash.a diff --git a/src/hash/aclocal.m4 b/src/hash/aclocal.m4 index 87a1009..59aa29e 100644 --- a/src/hash/aclocal.m4 +++ b/src/hash/aclocal.m4 @@ -1,4 +1,4 @@ -# generated automatically by aclocal 1.11.2 -*- Autoconf -*- +# generated automatically by aclocal 1.11.3 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, @@ -38,7 +38,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.11.2], [], +m4_if([$1], [1.11.3], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -54,7 +54,7 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.11.2])dnl +[AM_AUTOMAKE_VERSION([1.11.3])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) @@ -886,7 +886,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -908,10 +908,11 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], -[# Always define AMTAR for backward compatibility. -AM_MISSING_PROG([AMTAR], [tar]) +[# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AC_SUBST([AMTAR], ['$${TAR-tar}']) m4_if([$1], [v7], - [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) diff --git a/src/hash/configure b/src/hash/configure index 9b9e694..eb00ccd 100755 --- a/src/hash/configure +++ b/src/hash/configure @@ -2727,11 +2727,11 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. -# Always define AMTAR for backward compatibility. +# Always define AMTAR for backward compatibility. Yes, it's still used +# in the wild :-( We should find a proper way to deprecate it ... +AMTAR='$${TAR-tar}' -AMTAR=${AMTAR-"${am_missing_run}tar"} - -am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' +am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' diff --git a/src/missing b/src/missing index 28055d2..86a8fc3 100755 --- a/src/missing +++ b/src/missing @@ -1,10 +1,10 @@ #! /bin/sh # Common stub for a few missing GNU programs while installing. -scriptversion=2009-04-28.21; # UTC +scriptversion=2012-01-06.13; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, -# 2008, 2009 Free Software Foundation, Inc. +# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify @@ -84,7 +84,6 @@ Supported PROGRAM values: help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file - tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and @@ -122,15 +121,6 @@ case $1 in # Not GNU programs, they don't have --version. ;; - tar*) - if test -n "$run"; then - echo 1>&2 "ERROR: \`tar' requires --run" - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - exit 1 - fi - ;; - *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. @@ -226,7 +216,7 @@ WARNING: \`$1' $msg. You should only need it if \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then - eval LASTARG="\${$#}" + eval LASTARG=\${$#} case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` @@ -256,7 +246,7 @@ WARNING: \`$1' is $msg. You should only need it if \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then - eval LASTARG="\${$#}" + eval LASTARG=\${$#} case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` @@ -318,41 +308,6 @@ WARNING: \`$1' is $msg. You should only need it if touch $file ;; - tar*) - shift - - # We have already tried tar in the generic part. - # Look for gnutar/gtar before invocation to avoid ugly error - # messages. - if (gnutar --version > /dev/null 2>&1); then - gnutar "$@" && exit 0 - fi - if (gtar --version > /dev/null 2>&1); then - gtar "$@" && exit 0 - fi - firstarg="$1" - if shift; then - case $firstarg in - *o*) - firstarg=`echo "$firstarg" | sed s/o//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - case $firstarg in - *h*) - firstarg=`echo "$firstarg" | sed s/h//` - tar "$firstarg" "$@" && exit 0 - ;; - esac - fi - - echo 1>&2 "\ -WARNING: I can't seem to be able to run \`tar' with the given arguments. - You may want to install GNU tar or Free paxutils, or check the - command line arguments." - exit 1 - ;; - *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. diff --git a/src/socket.cpp b/src/socket.cpp index fa86e94..87d4397 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -79,70 +79,6 @@ int setblock(int fd) return 0; } -/** - * @brief non-blocking version connect - * - * @see - * @note - * @author auxten - * @date Apr 22, 2012 - **/ -int nb_connect(const s_host_t * h) -{ - int sock = -1; - int ret = -1; - struct sockaddr_in channel; - in_addr_t host; - int addr_len; - - addr_len = getaddr_my(h->addr, &host); - if (FAIL_CHECK(!addr_len)) - { - gko_log(WARNING, "gethostbyname %s error", h->addr); - ret = -1; - goto NB_CONNECT_END; - } - sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); - if (FAIL_CHECK(sock < 0)) - { - gko_log(WARNING, "get socket error"); - ret = -1; - goto NB_CONNECT_END; - } - - memset(&channel, 0, sizeof(channel)); - channel.sin_family = AF_INET; - memcpy(&channel.sin_addr.s_addr, &host, addr_len); - channel.sin_port = htons(h->port); - - /** set the connect non-blocking then blocking for add timeout on connect **/ - if (FAIL_CHECK(setnonblock(sock) < 0)) - { - gko_log(WARNING, "set socket non-blocking error"); - ret = -1; - goto NB_CONNECT_END; - } - - /** connect and send the msg **/ - if (FAIL_CHECK(connect(sock, (struct sockaddr *) &channel, sizeof(channel)) && - errno != EINPROGRESS)) - { - gko_log(WARNING, "connect error"); - ret = HOST_DOWN_FAIL; - goto NB_CONNECT_END; - } - - ret = sock; - - NB_CONNECT_END: - /// - if (ret < 0 && sock >= 0) - { - close_socket(sock); - } - return ret; -} - /** * @brief connect to a host *