glusterd: Fix removing pmap entry on rpc disconnect

Problem:
The following line of code intended to remove pmap entry for the
connection during disconnects:

    pmap_registry_remove (this, 0, NULL, GF_PMAP_PORT_NONE, xprt);

However, no pmap entry will have it's type set to GF_PMAP_PORT_NONE
at any point in time. So a call to pmap_registry_search_by_xprt() in
pmap_registry_remove() will always fail to find a match.

Fix:
Optionally ignore pmap entry's type in pmap_registry_search_by_xprt().

BUG: 1193929
Change-Id: I705f101739ab1647ff52a92820d478354407264a
Signed-off-by: Prashanth Pai <ppai@redhat.com>
Reviewed-on: https://review.gluster.org/17129
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
This commit is contained in:
Prashanth Pai 2017-04-27 18:26:02 +05:30 committed by Jeff Darcy
parent 83abcba6b4
commit 081f9febee
3 changed files with 11 additions and 9 deletions

View File

@ -106,7 +106,7 @@ enum gf_pmap_port_type {
GF_PMAP_PORT_FREE = 0,
GF_PMAP_PORT_FOREIGN, /* it actually means, not sure who is using it, but it is in-use */
GF_PMAP_PORT_LEASED,
GF_PMAP_PORT_NONE,
GF_PMAP_PORT_ANY,
GF_PMAP_PORT_BRICKSERVER, /* port used by brick process */
};
typedef enum gf_pmap_port_type gf_pmap_port_type_t;

View File

@ -27,7 +27,7 @@
#include <netinet/in.h>
int
static int
pmap_port_isfree (int port)
{
struct sockaddr_in sin;
@ -155,7 +155,7 @@ pmap_registry_search (xlator_t *this, const char *brickname,
return 0;
}
int
static int
pmap_registry_search_by_xprt (xlator_t *this, void *xprt,
gf_pmap_port_type_t type)
{
@ -168,10 +168,12 @@ pmap_registry_search_by_xprt (xlator_t *this, void *xprt,
for (p = pmap->last_alloc; p >= pmap->base_port; p--) {
if (!pmap->ports[p].xprt)
continue;
if (pmap->ports[p].xprt == xprt &&
pmap->ports[p].type == type) {
port = p;
break;
if (pmap->ports[p].xprt == xprt) {
if (pmap->ports[p].type == type ||
type == GF_PMAP_PORT_ANY) {
port = p;
break;
}
}
}
@ -179,7 +181,7 @@ pmap_registry_search_by_xprt (xlator_t *this, void *xprt,
}
char *
static char *
pmap_registry_search_by_port (xlator_t *this, int port)
{
struct pmap_registry *pmap = NULL;

View File

@ -424,7 +424,7 @@ glusterd_rpcsvc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
pthread_mutex_lock (&priv->xprt_lock);
list_del (&xprt->list);
pthread_mutex_unlock (&priv->xprt_lock);
pmap_registry_remove (this, 0, NULL, GF_PMAP_PORT_NONE, xprt);
pmap_registry_remove (this, 0, NULL, GF_PMAP_PORT_ANY, xprt);
break;
}