[Pacemaker] [libqb]Unlink of files bound to sockets

Grüninger, Andreas (LGL Extern) Andreas.Grueninger at lgl.bwl.de
Thu Dec 18 17:30:46 UTC 2014


I used the current trunk.
I could not find the unlink calls.

If domain sockets are used this two methods are used.

In ./lib/ipc_socket.c 
static void
qb_ipcc_us_disconnect(struct qb_ipcc_connection *c)
{
  munmap(c->request.u.us.shared_data, SHM_CONTROL_SIZE);
  unlink(c->request.u.us.shared_file_name);
  qb_ipcc_us_sock_close(c->event.u.us.sock);
  qb_ipcc_us_sock_close(c->request.u.us.sock);
  qb_ipcc_us_sock_close(c->setup.u.us.sock);
}

In ./lib/ipc_setup.c
void
qb_ipcc_us_sock_close(int32_t sock)
{
shutdown(sock, SHUT_RDWR);
close(sock);
}

I added in the latter the unlink calls.

-----Ursprüngliche Nachricht-----
Von: David Vossel [mailto:dvossel at redhat.com] 
Gesendet: Donnerstag, 18. Dezember 2014 18:13
An: The Pacemaker cluster resource manager
Betreff: Re: [Pacemaker] [libqb]Unlink of files bound to sockets



----- Original Message -----
> 
> 
> I sent yesterday this email to the mailing list of libq 
> 'quarterback-devel at lists.fedorahosted.org'.
> 
> But there is nearly no activity since august.

i saw the email. i flagged it so it would get a response.

> 
> I use the current trunk of libqb.
> 
> In qb_ipcc_us_sock_close nd qb_ipcs_us_withdraw of lib/ipc_setup.c 
> sockets are closed.
> 
> Is there a reason why the files bound to the sockets are not deleted 
> with unlink?
> 
> Is unlinking not necessary with Linux?

Unlinking is required for linux.

For client/server connections.

qb_ipcc_us_disconnect unlinks on the client side.
qb_ipcs_us_disconnect unlinks on the server side.


> I found thousands of files in statedir=/var/corosync/run after a while.

What version of corosync are you using? There were some reference leaks for ipc connections in the corosync code we fixed a year or so ago that should have fixed this.

-- David

> 
> 
> I tried this and it seems to work without errors.
> 
> 
> 
> e.g.
> 
> void
> 
> qb_ipcc_us_sock_close(int32_t sock)
> 
> {
> 
> #ifdef QB_SOLARIS
> 
> struct sockaddr_un un_addr;
> 
> socklen_t un_addr_len = sizeof(struct sockaddr_un);
> 
> #endif
> 
> shutdown(sock, SHUT_RDWR);
> 
> #ifdef QB_SOLARIS
> 
> if (getsockname(sock, (struct sockaddr *)&un_addr, &un_addr_len) == 0) 
> {
> 
> if(strstr(un_addr.sun_path,"-") != NULL) {
> 
> qb_util_log(LOG_DEBUG, "un_addr.sun_path=%s", un_addr.sun_path);
> 
> unlink(un_addr.sun_path);
> 
> }
> 
> } else {
> 
> qb_util_log(LOG_DEBUG, "getsockname returned errno=%d", errno);
> 
> }
> 
> #endif
> 
> close(sock);
> 
> }
> 
> 
> 
> Regards
> 
> 
> 
> Andreas
> 
> _______________________________________________
> Pacemaker mailing list: Pacemaker at oss.clusterlabs.org 
> http://oss.clusterlabs.org/mailman/listinfo/pacemaker
> 
> Project Home: http://www.clusterlabs.org Getting started: 
> http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
> Bugs: http://bugs.clusterlabs.org
> 

_______________________________________________
Pacemaker mailing list: Pacemaker at oss.clusterlabs.org http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://bugs.clusterlabs.org




More information about the Pacemaker mailing list