-/* 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.
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>
#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"
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;
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)
break;
default:
svc_getreq_poll (my_pollfd, i);
- free (my_pollfd);
if (data->nomore)
return data->result;
}
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;
}
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)
{
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)