Return-Path: X-Original-To: apmail-zookeeper-commits-archive@www.apache.org Delivered-To: apmail-zookeeper-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5BEFE184E1 for ; Fri, 30 Oct 2015 23:57:42 +0000 (UTC) Received: (qmail 72508 invoked by uid 500); 30 Oct 2015 23:57:42 -0000 Delivered-To: apmail-zookeeper-commits-archive@zookeeper.apache.org Received: (qmail 72476 invoked by uid 500); 30 Oct 2015 23:57:42 -0000 Mailing-List: contact commits-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ Delivered-To: mailing list commits@zookeeper.apache.org Received: (qmail 72464 invoked by uid 99); 30 Oct 2015 23:57:42 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Oct 2015 23:57:42 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id B7E6EC1790 for ; Fri, 30 Oct 2015 23:57:41 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.8 X-Spam-Level: X-Spam-Status: No, score=0.8 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-1] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id iAKymwKbtK2S for ; Fri, 30 Oct 2015 23:57:40 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTP id BC14D20524 for ; Fri, 30 Oct 2015 23:57:39 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id E9DE7E042E for ; Fri, 30 Oct 2015 23:57:38 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id CA6273A0288 for ; Fri, 30 Oct 2015 23:57:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1711566 - in /zookeeper/branches/branch-3.4: CHANGES.txt src/c/src/mt_adaptor.c src/c/src/st_adaptor.c src/c/src/zk_adaptor.h src/c/src/zookeeper.c Date: Fri, 30 Oct 2015 23:57:38 -0000 To: commits@zookeeper.apache.org From: cnauroth@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151030235738.CA6273A0288@svn01-us-west.apache.org> Author: cnauroth Date: Fri Oct 30 23:57:38 2015 New Revision: 1711566 URL: http://svn.apache.org/viewvc?rev=1711566&view=rev Log: ZOOKEEPER-1029: C client bug in zookeeper_init (if bad hostname is given) (fpj via cnauroth) Modified: zookeeper/branches/branch-3.4/CHANGES.txt zookeeper/branches/branch-3.4/src/c/src/mt_adaptor.c zookeeper/branches/branch-3.4/src/c/src/st_adaptor.c zookeeper/branches/branch-3.4/src/c/src/zk_adaptor.h zookeeper/branches/branch-3.4/src/c/src/zookeeper.c Modified: zookeeper/branches/branch-3.4/CHANGES.txt URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/CHANGES.txt?rev=1711566&r1=1711565&r2=1711566&view=diff ============================================================================== --- zookeeper/branches/branch-3.4/CHANGES.txt (original) +++ zookeeper/branches/branch-3.4/CHANGES.txt Fri Oct 30 23:57:38 2015 @@ -135,6 +135,9 @@ BUGFIXES: ZOOKEEPER-2296: compilation broken for 3.4 (Raul Gutierrez Segales via cnauroth) + ZOOKEEPER-1029: C client bug in zookeeper_init (if bad hostname is given) + (fpj via cnauroth) + IMPROVEMENTS: ZOOKEEPER-1575. adding .gitattributes to prevent CRLF and LF mismatches for Modified: zookeeper/branches/branch-3.4/src/c/src/mt_adaptor.c URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/c/src/mt_adaptor.c?rev=1711566&r1=1711565&r2=1711566&view=diff ============================================================================== --- zookeeper/branches/branch-3.4/src/c/src/mt_adaptor.c (original) +++ zookeeper/branches/branch-3.4/src/c/src/mt_adaptor.c Fri Oct 30 23:57:38 2015 @@ -44,30 +44,30 @@ #include #endif -void zoo_lock_auth(zhandle_t *zh) +int zoo_lock_auth(zhandle_t *zh) { - pthread_mutex_lock(&zh->auth_h.lock); + return pthread_mutex_lock(&zh->auth_h.lock); } -void zoo_unlock_auth(zhandle_t *zh) +int zoo_unlock_auth(zhandle_t *zh) { - pthread_mutex_unlock(&zh->auth_h.lock); + return pthread_mutex_unlock(&zh->auth_h.lock); } -void lock_buffer_list(buffer_head_t *l) +int lock_buffer_list(buffer_head_t *l) { - pthread_mutex_lock(&l->lock); + return pthread_mutex_lock(&l->lock); } -void unlock_buffer_list(buffer_head_t *l) +int unlock_buffer_list(buffer_head_t *l) { - pthread_mutex_unlock(&l->lock); + return pthread_mutex_unlock(&l->lock); } -void lock_completion_list(completion_head_t *l) +int lock_completion_list(completion_head_t *l) { - pthread_mutex_lock(&l->lock); + return pthread_mutex_lock(&l->lock); } -void unlock_completion_list(completion_head_t *l) +int unlock_completion_list(completion_head_t *l) { pthread_cond_broadcast(&l->cond); - pthread_mutex_unlock(&l->lock); + return pthread_mutex_unlock(&l->lock); } struct sync_completion *alloc_sync_completion(void) { @@ -515,16 +515,22 @@ __attribute__((constructor)) int32_t get return fetch_and_add(&xid,1); } -void enter_critical(zhandle_t* zh) +int enter_critical(zhandle_t* zh) { struct adaptor_threads *adaptor = zh->adaptor_priv; - if(adaptor) - pthread_mutex_lock(&adaptor->zh_lock); + if (adaptor) { + return pthread_mutex_lock(&adaptor->zh_lock); + } else { + return 0; + } } -void leave_critical(zhandle_t* zh) +int leave_critical(zhandle_t* zh) { struct adaptor_threads *adaptor = zh->adaptor_priv; - if(adaptor) - pthread_mutex_unlock(&adaptor->zh_lock); + if (adaptor) { + return pthread_mutex_unlock(&adaptor->zh_lock); + } else { + return 0; + } } Modified: zookeeper/branches/branch-3.4/src/c/src/st_adaptor.c URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/c/src/st_adaptor.c?rev=1711566&r1=1711565&r2=1711566&view=diff ============================================================================== --- zookeeper/branches/branch-3.4/src/c/src/st_adaptor.c (original) +++ zookeeper/branches/branch-3.4/src/c/src/st_adaptor.c Fri Oct 30 23:57:38 2015 @@ -24,23 +24,29 @@ #include #include -void zoo_lock_auth(zhandle_t *zh) +int zoo_lock_auth(zhandle_t *zh) { + return 0; } -void zoo_unlock_auth(zhandle_t *zh) +int zoo_unlock_auth(zhandle_t *zh) { + return 0; } -void lock_buffer_list(buffer_head_t *l) +int lock_buffer_list(buffer_head_t *l) { + return 0; } -void unlock_buffer_list(buffer_head_t *l) +int unlock_buffer_list(buffer_head_t *l) { + return 0; } -void lock_completion_list(completion_head_t *l) +int lock_completion_list(completion_head_t *l) { + return 0; } -void unlock_completion_list(completion_head_t *l) +int unlock_completion_list(completion_head_t *l) { + return 0; } struct sync_completion *alloc_sync_completion(void) { @@ -95,5 +101,13 @@ int32_t get_xid() } return xid++; } -void enter_critical(zhandle_t* zh){} -void leave_critical(zhandle_t* zh){} + +int enter_critical(zhandle_t* zh) +{ + return 0; +} + +int leave_critical(zhandle_t* zh) +{ + return 0; +} Modified: zookeeper/branches/branch-3.4/src/c/src/zk_adaptor.h URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/c/src/zk_adaptor.h?rev=1711566&r1=1711565&r2=1711566&view=diff ============================================================================== --- zookeeper/branches/branch-3.4/src/c/src/zk_adaptor.h (original) +++ zookeeper/branches/branch-3.4/src/c/src/zk_adaptor.h Fri Oct 30 23:57:38 2015 @@ -75,10 +75,10 @@ typedef struct _completion_head { #endif } completion_head_t; -void lock_buffer_list(buffer_head_t *l); -void unlock_buffer_list(buffer_head_t *l); -void lock_completion_list(completion_head_t *l); -void unlock_completion_list(completion_head_t *l); +int lock_buffer_list(buffer_head_t *l); +int unlock_buffer_list(buffer_head_t *l); +int lock_completion_list(completion_head_t *l); +int unlock_completion_list(completion_head_t *l); struct sync_completion { int rc; @@ -243,12 +243,12 @@ void process_completions(zhandle_t *zh); int flush_send_queue(zhandle_t*zh, int timeout); char* sub_string(zhandle_t *zh, const char* server_path); void free_duplicate_path(const char* free_path, const char* path); -void zoo_lock_auth(zhandle_t *zh); -void zoo_unlock_auth(zhandle_t *zh); +int zoo_lock_auth(zhandle_t *zh); +int zoo_unlock_auth(zhandle_t *zh); // critical section guards -void enter_critical(zhandle_t* zh); -void leave_critical(zhandle_t* zh); +int enter_critical(zhandle_t* zh); +int leave_critical(zhandle_t* zh); // zhandle object reference counting void api_prolog(zhandle_t* zh); int api_epilog(zhandle_t *zh, int rc); Modified: zookeeper/branches/branch-3.4/src/c/src/zookeeper.c URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/c/src/zookeeper.c?rev=1711566&r1=1711565&r2=1711566&view=diff ============================================================================== --- zookeeper/branches/branch-3.4/src/c/src/zookeeper.c (original) +++ zookeeper/branches/branch-3.4/src/c/src/zookeeper.c Fri Oct 30 23:57:38 2015 @@ -1150,52 +1150,57 @@ void free_completions(zhandle_t *zh,int void_completion_t auth_completion = NULL; auth_completion_list_t a_list, *a_tmp; - lock_completion_list(&zh->sent_requests); - tmp_list = zh->sent_requests; - zh->sent_requests.head = 0; - zh->sent_requests.last = 0; - unlock_completion_list(&zh->sent_requests); - while (tmp_list.head) { - completion_list_t *cptr = tmp_list.head; + if (lock_completion_list(&zh->sent_requests) == 0) { + tmp_list = zh->sent_requests; + zh->sent_requests.head = 0; + zh->sent_requests.last = 0; + unlock_completion_list(&zh->sent_requests); + + while (tmp_list.head) { + completion_list_t *cptr = tmp_list.head; - tmp_list.head = cptr->next; - if (cptr->c.data_result == SYNCHRONOUS_MARKER) { - struct sync_completion - *sc = (struct sync_completion*)cptr->data; - sc->rc = reason; - notify_sync_completion(sc); - zh->outstanding_sync--; - destroy_completion_entry(cptr); - } else if (callCompletion) { - // Fake the response - buffer_list_t *bptr; - h.xid = cptr->xid; - h.zxid = -1; - h.err = reason; - oa = create_buffer_oarchive(); - serialize_ReplyHeader(oa, "header", &h); - bptr = calloc(sizeof(*bptr), 1); - assert(bptr); - bptr->len = get_buffer_len(oa); - bptr->buffer = get_buffer(oa); - close_buffer_oarchive(&oa, 0); - cptr->buffer = bptr; - queue_completion(&zh->completions_to_process, cptr, 0); + tmp_list.head = cptr->next; + if (cptr->c.data_result == SYNCHRONOUS_MARKER) { + struct sync_completion + *sc = (struct sync_completion*)cptr->data; + sc->rc = reason; + notify_sync_completion(sc); + zh->outstanding_sync--; + destroy_completion_entry(cptr); + } else if (callCompletion) { + // Fake the response + buffer_list_t *bptr; + h.xid = cptr->xid; + h.zxid = -1; + h.err = reason; + oa = create_buffer_oarchive(); + serialize_ReplyHeader(oa, "header", &h); + bptr = calloc(sizeof(*bptr), 1); + assert(bptr); + bptr->len = get_buffer_len(oa); + bptr->buffer = get_buffer(oa); + close_buffer_oarchive(&oa, 0); + cptr->buffer = bptr; + queue_completion(&zh->completions_to_process, cptr, 0); + } } } - a_list.completion = NULL; - a_list.next = NULL; - zoo_lock_auth(zh); - get_auth_completions(&zh->auth_h, &a_list); - zoo_unlock_auth(zh); - a_tmp = &a_list; - // chain call user's completion function - while (a_tmp->completion != NULL) { - auth_completion = a_tmp->completion; - auth_completion(reason, a_tmp->auth_data); - a_tmp = a_tmp->next; - if (a_tmp == NULL) - break; + if (zoo_lock_auth(zh) == 0) { + a_list.completion = NULL; + a_list.next = NULL; + + get_auth_completions(&zh->auth_h, &a_list); + zoo_unlock_auth(zh); + + a_tmp = &a_list; + // chain call user's completion function + while (a_tmp->completion != NULL) { + auth_completion = a_tmp->completion; + auth_completion(reason, a_tmp->auth_data); + a_tmp = a_tmp->next; + if (a_tmp == NULL) + break; + } } free_auth_completion(&a_list); }