]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nis/nis_callback.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / nis / nis_callback.c
index 6582315c7085b35cbedca6b9ef68625be1339d83..1668e29ea9de688d9d35b000871a549635be5e08 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997,1998,1999,2000,2005,2006 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@suse.de>, 1997.
 
@@ -13,9 +13,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
 #include <stdio.h>
@@ -34,7 +33,7 @@
 #include <rpc/key_prot.h>
 #include <rpcsvc/nis.h>
 #include <rpcsvc/nis_callback.h>
-#include <bits/libc-lock.h>
+#include <libc-lock.h>
 
 #include "nis_xdr.h"
 #include "nis_intern.h"
@@ -197,22 +196,18 @@ internal_nis_do_callback (struct dir_binding *bptr, netobj *cookie,
                          struct nis_cb *cb)
 {
   struct timeval TIMEOUT = {25, 0};
-  bool_t cb_is_running = FALSE;
+  bool_t cb_is_running;
 
   data = cb;
 
   for (;;)
     {
-      struct pollfd *my_pollfd;
+      struct pollfd my_pollfd[svc_max_pollfd];
       int i;
 
       if (svc_max_pollfd == 0 && svc_pollfd == NULL)
         return NIS_CBERROR;
 
-      my_pollfd = malloc (sizeof (struct pollfd) * svc_max_pollfd);
-      if (__builtin_expect (my_pollfd == NULL, 0))
-       return NIS_NOMEMORY;
-
       for (i = 0; i < svc_max_pollfd; ++i)
         {
           my_pollfd[i].fd = svc_pollfd[i].fd;
@@ -220,20 +215,17 @@ internal_nis_do_callback (struct dir_binding *bptr, netobj *cookie,
           my_pollfd[i].revents = 0;
         }
 
-      switch (i = __poll (my_pollfd, svc_max_pollfd, 25*1000))
+      switch (i = TEMP_FAILURE_RETRY (__poll (my_pollfd, svc_max_pollfd,
+                                             25*1000)))
         {
        case -1:
-         free (my_pollfd);
-         if (errno == EINTR)
-           continue;
          return NIS_CBERROR;
        case 0:
-         free (my_pollfd);
          /* See if callback 'thread' in the server is still alive. */
-         memset ((char *) &cb_is_running, 0, sizeof (cb_is_running));
+         cb_is_running = FALSE;
          if (clnt_call (bptr->clnt, NIS_CALLBACK, (xdrproc_t) xdr_netobj,
                         (caddr_t) cookie, (xdrproc_t) xdr_bool,
-                        (caddr_t) & cb_is_running, TIMEOUT) != RPC_SUCCESS)
+                        (caddr_t) &cb_is_running, TIMEOUT) != RPC_SUCCESS)
            cb_is_running = FALSE;
 
          if (cb_is_running == FALSE)
@@ -244,7 +236,6 @@ internal_nis_do_callback (struct dir_binding *bptr, netobj *cookie,
          break;
        default:
          svc_getreq_poll (my_pollfd, i);
-         free (my_pollfd);
          if (data->nomore)
            return data->result;
        }
@@ -280,18 +271,18 @@ __nis_create_callback (int (*callback) (const_nis_name, const nis_object *,
 
   cb = (struct nis_cb *) calloc (1,
                                 sizeof (struct nis_cb) + sizeof (nis_server));
-  if (__builtin_expect (cb == NULL, 0))
+  if (__glibc_unlikely (cb == NULL))
     goto failed;
   cb->serv = (nis_server *) (cb + 1);
   cb->serv->name = strdup (nis_local_principal ());
-  if (__builtin_expect (cb->serv->name == NULL, 0))
+  if (__glibc_unlikely (cb->serv->name == NULL))
     goto failed;
   cb->serv->ep.ep_val = (endpoint *) calloc (2, sizeof (endpoint));
-  if (__builtin_expect (cb->serv->ep.ep_val == NULL, 0))
+  if (__glibc_unlikely (cb->serv->ep.ep_val == NULL))
     goto failed;
   cb->serv->ep.ep_len = 1;
   cb->serv->ep.ep_val[0].family = strdup ("inet");
-  if (__builtin_expect (cb->serv->ep.ep_val[0].family == NULL, 0))
+  if (__glibc_unlikely (cb->serv->ep.ep_val[0].family == NULL))
     goto failed;
   cb->callback = callback;
   cb->userdata = userdata;
@@ -323,7 +314,7 @@ __nis_create_callback (int (*callback) (const_nis_name, const nis_object *,
     }
 
   cb->serv->ep.ep_val[0].proto = strdup ((flags & USE_DGRAM) ? "udp" : "tcp");
-  if (__builtin_expect (cb->serv->ep.ep_val[0].proto == NULL, 0))
+  if (__glibc_unlikely (cb->serv->ep.ep_val[0].proto == NULL))
     goto failed;
   cb->xprt = ((flags & USE_DGRAM)
              ? svcudp_bufcreate (sock, 100, 8192)
@@ -368,8 +359,7 @@ __nis_create_callback (int (*callback) (const_nis_name, const nis_object *,
     {
       if (cb->xprt)
        svc_destroy (cb->xprt);
-      if (cb->serv)
-       xdr_free ((xdrproc_t) _xdr_nis_server, (char *) cb->serv);
+      xdr_free ((xdrproc_t) _xdr_nis_server, (char *) cb->serv);
       free (cb);
     }
   if (!nomsg)