From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29803 invoked by alias); 24 Jan 2013 18:48:14 -0000 Received: (qmail 29690 invoked by uid 22791); 24 Jan 2013 18:48:12 -0000 X-SWARE-Spam-Status: No, hits=-7.7 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Jan 2013 18:48:05 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0OIm2lE027495 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 24 Jan 2013 13:48:03 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0OIm0Ns021641; Thu, 24 Jan 2013 13:48:01 -0500 Message-ID: <510181E0.4060808@redhat.com> Date: Thu, 24 Jan 2013 18:48:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Yao Qi CC: gdb-patches@sourceware.org Subject: Re: [PATCH 1/3] gdbserver: replace event_queue with QUEUE References: <1358990040-10962-1-git-send-email-yao@codesourcery.com> In-Reply-To: <1358990040-10962-1-git-send-email-yao@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-01/txt/msg00607.txt.bz2 On 01/24/2013 01:13 AM, Yao Qi wrote: > - > /* Process one event. If an event was processed, 1 is returned > otherwise 0 is returned. Scan the queue from head to tail, > processing therefore the high priority events first, by invoking > @@ -199,46 +161,18 @@ async_queue_event (gdb_event *event_ptr) > static int > process_event (void) > { ... > - free (event_ptr); > + gdb_event *event_ptr = QUEUE_deque (gdb_event_p, event_queue); > + event_handler_func *proc = event_ptr->proc; > + gdb_fildes_t fd = event_ptr->fd; > > + xfree (event_ptr); I think here gdb_event_xfree (event_ptr); would be better. > /* Start up the event loop. This is the entry point to the event > loop. */ > > void > start_event_loop (void) > { > + event_queue = QUEUE_alloc (gdb_event_p, gdb_event_xfree); This will go wrong if we ever nest event loops. Can you put this in a initialize_event_loop function instead, called from main, close to the initialize_low, etc. calls, please? Okay with that change. -- Pedro Alves