From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5357 invoked by alias); 14 Jun 2012 14:44:06 -0000 Received: (qmail 5279 invoked by uid 22791); 14 Jun 2012 14:44:04 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,TW_XS X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 14 Jun 2012 14:43:47 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1SfBH0-0003HS-IR from Yao_Qi@mentor.com ; Thu, 14 Jun 2012 07:43:46 -0700 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Thu, 14 Jun 2012 07:43:10 -0700 Received: from yaolp.localnet (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.1.289.1; Thu, 14 Jun 2012 07:43:45 -0700 From: Yao Qi To: Pedro Alves Subject: Re: [PATCH 2/4] Remove socket file at exit. Date: Thu, 14 Jun 2012 14:44:00 -0000 User-Agent: KMail/1.13.5 (Linux/2.6.32-41-generic; KDE/4.4.5; i686; ; ) CC: References: <1339246002-1987-1-git-send-email-yao@codesourcery.com> <1339246002-1987-3-git-send-email-yao@codesourcery.com> <4FD75CD8.4020704@redhat.com> In-Reply-To: <4FD75CD8.4020704@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <201206142243.42819.yao@codesourcery.com> X-IsSubscribed: yes 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/msg00467.txt.bz2 On Tuesday 12 June 2012 23:14:32 Pedro Alves wrote: > > (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.) At first, I tried to avoid introducing a global variable, so I inlined that function. Forgot to revert change back. Fixed. gdb/gdbserver: 2012-06-14 Yao Qi * tracepoint.c (agent_socket_name): New static variable. (gdb_agent_socket_init): Replace local variable 'name' with 'agent_socket_name'. Include 'stdlib.h'. (gdb_agent_remove_socket): New. (gdb_agent_helper_thread): Install gdb_agent_remove_socket to atexit hook. --- gdb/gdbserver/tracepoint.c | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c index f103dfc..8fcaa46 100644 --- a/gdb/gdbserver/tracepoint.c +++ b/gdb/gdbserver/tracepoint.c @@ -6748,13 +6748,14 @@ init_named_socket (const char *name) return fd; } +static char agent_socket_name[UNIX_PATH_MAX]; + 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", + result = xsnprintf (agent_socket_name, UNIX_PATH_MAX, "%s/gdb_ust%d", SOCK_DIR, getpid ()); if (result >= UNIX_PATH_MAX) { @@ -6762,11 +6763,11 @@ gdb_agent_socket_init (void) return -1; } - fd = init_named_socket (name); + fd = init_named_socket (agent_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); + "is writable.", agent_socket_name); return fd; } @@ -6995,6 +6996,13 @@ gdb_ust_init (void) #endif /* HAVE_UST */ #include +#include + +static void +gdb_agent_remove_socket (void) +{ + unlink (agent_socket_name); +} /* Helper thread of agent. */ @@ -7003,6 +7011,8 @@ gdb_agent_helper_thread (void *arg) { int listen_fd; + atexit (gdb_agent_remove_socket); + while (1) { listen_fd = gdb_agent_socket_init (); -- 1.7.0.4