X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=utils%2Fstatd%2Fsm-notify.c;h=78d0a592bcf181eb09e4b3e61bb9708bf2915cd0;hb=3ab7ab5db0f825fdd95d017cdd6d6ee5d207dbe8;hp=f1fc619a9b4c3ab9398e27d073af588d81bdf31a;hpb=c88c4091db87c0fc23ed67e76d63439b59a82369;p=nfs-utils.git diff --git a/utils/statd/sm-notify.c b/utils/statd/sm-notify.c index f1fc619..78d0a59 100644 --- a/utils/statd/sm-notify.c +++ b/utils/statd/sm-notify.c @@ -424,19 +424,27 @@ notify_host(int sock, struct nsm_host *host) * point. */ if (host->retries >= 4) { - struct addrinfo *first = host->ai; - struct addrinfo **next = &host->ai; - - /* remove the first entry from the list */ - host->ai = first->ai_next; - first->ai_next = NULL; - /* find the end of the list */ - next = &first->ai_next; - while ( *next ) - next = & (*next)->ai_next; - /* put first entry at end */ - *next = first; - memcpy(&host->addr, first->ai_addr, first->ai_addrlen); + /* don't rotate if there is only one addrinfo */ + if (host->ai->ai_next == NULL) + memcpy(&host->addr, host->ai->ai_addr, + host->ai->ai_addrlen); + else { + struct addrinfo *first = host->ai; + struct addrinfo **next = &host->ai; + + /* remove the first entry from the list */ + host->ai = first->ai_next; + first->ai_next = NULL; + /* find the end of the list */ + next = &first->ai_next; + while ( *next ) + next = & (*next)->ai_next; + /* put first entry at end */ + *next = first; + memcpy(&host->addr, first->ai_addr, + first->ai_addrlen); + } + smn_set_port((struct sockaddr *)&host->addr, 0); host->retries = 0; }