From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28780 invoked by alias); 12 Jun 2012 15:14:59 -0000 Received: (qmail 28753 invoked by uid 22791); 12 Jun 2012 15:14:55 -0000 X-SWARE-Spam-Status: No, hits=-7.4 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,TW_XS,T_RP_MATCHES_RCVD 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; Tue, 12 Jun 2012 15:14:37 +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 q5CFEXHU009009 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 12 Jun 2012 11:14:33 -0400 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 q5CFEWSh020303; Tue, 12 Jun 2012 11:14:32 -0400 Message-ID: <4FD75CD8.4020704@redhat.com> Date: Tue, 12 Jun 2012 15:14:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Yao Qi CC: gdb-patches@sourceware.org Subject: Re: [PATCH 2/4] Remove socket file at exit. References: <1339246002-1987-1-git-send-email-yao@codesourcery.com> <1339246002-1987-3-git-send-email-yao@codesourcery.com> In-Reply-To: <1339246002-1987-3-git-send-email-yao@codesourcery.com> Content-Type: text/plain; charset=UTF-8 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: 2012-06/txt/msg00351.txt.bz2 On 06/09/2012 01:46 PM, Yao Qi wrote: > This patch is to add code to call 'unlink' to make sure agent can remove socket > when inferior (after detached from GDB/GDBserver) exits. It fixes the fail > below: > > FAIL: gdb.trace/strace.exp: remove_socket_after_detach: socket file removed > (Just as reminder, ideally, at check in time, the patches would be sequenced to not introduce any FAILs along the way.) > gdb/gdbserver: > > 2012-06-09 Yao Qi > > PR gdb/14161. > * tracepoint.c (gdb_agent_socket_init): Removed. "Remove". > (gdb_agent_remove_socket): New. > (gdb_agent_helper_thread): Call gdb_agent_remove_socket at > exit. > Inline gdb_agent_socket_init here. But why inline? We should just need to move the "name" local of gdb_agent_socket_init a global? (btw, the 'agent_socket_name' global is missing from the ChangeLog.) > --- > gdb/gdbserver/tracepoint.c | 56 +++++++++++++++++++++---------------------- > 1 files changed, 27 insertions(+), 29 deletions(-) > > diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c > index f103dfc..4e6c3ec 100644 > --- a/gdb/gdbserver/tracepoint.c > +++ b/gdb/gdbserver/tracepoint.c > @@ -6748,29 +6748,6 @@ init_named_socket (const char *name) > return fd; > } > > -static int > -gdb_agent_socket_init (void) > -{ > - int result, fd; > - char name[UNIX_PATH_MAX]; > - > - result = xsnprintf (name, UNIX_PATH_MAX, "%s/gdb_ust%d", > - SOCK_DIR, getpid ()); > - if (result >= UNIX_PATH_MAX) > - { > - trace_debug ("string overflow allocating socket name"); > - return -1; > - } > - > - fd = init_named_socket (name); > - if (fd < 0) > - warning ("Error initializing named socket (%s) for communication with the " > - "ust helper thread. Check that directory exists and that it " > - "is writable.", name); > - > - return fd; > -} > - > #ifdef HAVE_UST > > /* The next marker to be returned on a qTsSTM command. */ > @@ -6995,27 +6972,48 @@ gdb_ust_init (void) > #endif /* HAVE_UST */ > > #include > +#include > + > +static char agent_socket_name[UNIX_PATH_MAX]; > + > +static void > +gdb_agent_remove_socket (void) > +{ > + unlink (agent_socket_name); > +} > > /* Helper thread of agent. */ > > static void * > gdb_agent_helper_thread (void *arg) > { > - int listen_fd; > + atexit (gdb_agent_remove_socket); > > while (1) > { > - listen_fd = gdb_agent_socket_init (); > + int listen_fd, result; > > - if (helper_thread_id == 0) > - helper_thread_id = syscall (SYS_gettid); > + result = xsnprintf (agent_socket_name, UNIX_PATH_MAX, "%s/gdb_ust%d", > + SOCK_DIR, getpid ()); > + if (result >= UNIX_PATH_MAX) > + { > + trace_debug ("string overflow allocating socket name"); > + break; > + } > > - if (listen_fd == -1) > + listen_fd = init_named_socket (agent_socket_name); > + if (listen_fd < 0) > { > - warning ("could not create sync socket\n"); > + warning ("Error initializing named socket (%s) for communication " > + "with the ust helper thread. Check that directory exists" > + " and that it is writable.", agent_socket_name); > break; > + > } > > + if (helper_thread_id == 0) > + helper_thread_id = syscall (SYS_gettid); > + > while (1) > { > socklen_t tmp; -- Pedro Alves