mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-05 01:00:14 +00:00
Update.
* nis/nis_callback.c (__nis_create_callback): Partially undo last patch. Keep needed tests for failed memory allocation.
This commit is contained in:
parent
e19ae111e9
commit
6d5728c8dd
@ -1,5 +1,8 @@
|
|||||||
2000-04-24 Ulrich Drepper <drepper@redhat.com>
|
2000-04-24 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* nis/nis_callback.c (__nis_create_callback): Partially undo last
|
||||||
|
patch. Keep needed tests for failed memory allocation.
|
||||||
|
|
||||||
* elf/dl-reloc.c (_dl_relocate_object): Add one more
|
* elf/dl-reloc.c (_dl_relocate_object): Add one more
|
||||||
__builtin_expect saying that we don't normally expect to profile.
|
__builtin_expect saying that we don't normally expect to profile.
|
||||||
|
|
||||||
|
@ -206,12 +206,12 @@ internal_nis_do_callback (struct dir_binding *bptr, netobj *cookie,
|
|||||||
struct pollfd *my_pollfd;
|
struct pollfd *my_pollfd;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (__builtin_expect (svc_max_pollfd, 1) == 0
|
if (svc_max_pollfd == 0 && svc_pollfd == NULL)
|
||||||
&& __builtin_expect (svc_pollfd == NULL, 0))
|
|
||||||
return NIS_CBERROR;
|
return NIS_CBERROR;
|
||||||
|
|
||||||
my_pollfd = (struct pollfd *) alloca (sizeof (struct pollfd)
|
my_pollfd = malloc (sizeof (struct pollfd) * svc_max_pollfd);
|
||||||
* svc_max_pollfd);
|
if (__builtin_expect (my_pollfd == NULL, 0))
|
||||||
|
return NIS_NOMEMORY;
|
||||||
|
|
||||||
for (i = 0; i < svc_max_pollfd; ++i)
|
for (i = 0; i < svc_max_pollfd; ++i)
|
||||||
{
|
{
|
||||||
@ -220,13 +220,15 @@ internal_nis_do_callback (struct dir_binding *bptr, netobj *cookie,
|
|||||||
my_pollfd[i].revents = 0;
|
my_pollfd[i].revents = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (i = __poll (my_pollfd, svc_max_pollfd, 25 * 1000))
|
switch (i = __poll (my_pollfd, svc_max_pollfd, 25*1000))
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
|
free (my_pollfd);
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
return NIS_CBERROR;
|
return NIS_CBERROR;
|
||||||
case 0:
|
case 0:
|
||||||
|
free (my_pollfd);
|
||||||
/* See if callback 'thread' in the server is still alive. */
|
/* See if callback 'thread' in the server is still alive. */
|
||||||
memset ((char *) &cb_is_running, 0, sizeof (cb_is_running));
|
memset ((char *) &cb_is_running, 0, sizeof (cb_is_running));
|
||||||
if (clnt_call (bptr->clnt, NIS_CALLBACK, (xdrproc_t) xdr_netobj,
|
if (clnt_call (bptr->clnt, NIS_CALLBACK, (xdrproc_t) xdr_netobj,
|
||||||
@ -242,6 +244,7 @@ internal_nis_do_callback (struct dir_binding *bptr, netobj *cookie,
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
svc_getreq_poll (my_pollfd, i);
|
svc_getreq_poll (my_pollfd, i);
|
||||||
|
free (my_pollfd);
|
||||||
if (data->nomore)
|
if (data->nomore)
|
||||||
return data->result;
|
return data->result;
|
||||||
}
|
}
|
||||||
@ -276,26 +279,29 @@ __nis_create_callback (int (*callback) (const_nis_name, const nis_object *,
|
|||||||
unsigned short port;
|
unsigned short port;
|
||||||
|
|
||||||
cb = (struct nis_cb *) calloc (1, sizeof (struct nis_cb));
|
cb = (struct nis_cb *) calloc (1, sizeof (struct nis_cb));
|
||||||
if (__builtin_expect (cb == NULL, 0))
|
if (__builtin_expect (cb == NULL, ))
|
||||||
goto free_oom;
|
{
|
||||||
|
syslog (LOG_ERR, "NIS+: out of memory allocating callback");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
cb->serv = (nis_server *) calloc (1, sizeof (nis_server));
|
cb->serv = (nis_server *) calloc (1, sizeof (nis_server));
|
||||||
if (__builtin_expect (cb->serv == NULL, 0))
|
if (__builtin_expect (cb->serv == NULL, 0))
|
||||||
goto free_cb;
|
{
|
||||||
|
free (cb);
|
||||||
|
syslog (LOG_ERR, "NIS+: out of memory allocating callback");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
cb->serv->name = strdup (nis_local_principal ());
|
cb->serv->name = strdup (nis_local_principal ());
|
||||||
if (__builtin_expect (cb->serv->name == NULL, 0))
|
if (__builtin_expect (cb->serv->name == NULL, 0))
|
||||||
goto free_serv;
|
return NIS_NOMEMORY;
|
||||||
|
|
||||||
cb->serv->ep.ep_val = (endpoint *) calloc (2, sizeof (endpoint));
|
cb->serv->ep.ep_val = (endpoint *) calloc (2, sizeof (endpoint));
|
||||||
if (__builtin_expect (cb->serv->ep.ep_val == NULL, 0))
|
if (__builtin_expect (cb->serv->ep.ep_val == NULL, 0))
|
||||||
goto free_name;
|
return NIS_NOMEMORY;
|
||||||
|
|
||||||
cb->serv->ep.ep_len = 1;
|
cb->serv->ep.ep_len = 1;
|
||||||
cb->serv->ep.ep_val[0].family = strdup ("inet");
|
cb->serv->ep.ep_val[0].family = strdup ("inet");
|
||||||
if (__builtin_expect (cb->serv->ep.ep_val[0].family == NULL, 0))
|
if (__builtin_expect (cb->serv->ep.ep_val[0].family == NULL, 0))
|
||||||
goto free_ep_val;
|
return NIS_NOMEMORY;
|
||||||
|
|
||||||
cb->callback = callback;
|
cb->callback = callback;
|
||||||
cb->userdata = userdata;
|
cb->userdata = userdata;
|
||||||
|
|
||||||
@ -335,20 +341,14 @@ __nis_create_callback (int (*callback) (const_nis_name, const nis_object *,
|
|||||||
cb->serv->ep.ep_val[0].proto = strdup ("tcp");
|
cb->serv->ep.ep_val[0].proto = strdup ("tcp");
|
||||||
cb->xprt = svctcp_create (sock, 100, 8192);
|
cb->xprt = svctcp_create (sock, 100, 8192);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__builtin_expect (cb->serv->ep.ep_val[0].proto == NULL, 0))
|
if (__builtin_expect (cb->serv->ep.ep_val[0].proto == NULL, 0))
|
||||||
goto free_family;
|
return NIS_NOMEMORY;
|
||||||
|
|
||||||
cb->sock = cb->xprt->xp_sock;
|
cb->sock = cb->xprt->xp_sock;
|
||||||
if (!svc_register (cb->xprt, CB_PROG, CB_VERS, cb_prog_1, 0))
|
if (!svc_register (cb->xprt, CB_PROG, CB_VERS, cb_prog_1, 0))
|
||||||
{
|
{
|
||||||
xprt_unregister (cb->xprt);
|
xprt_unregister (cb->xprt);
|
||||||
svc_destroy (cb->xprt);
|
svc_destroy (cb->xprt);
|
||||||
xdr_free ((xdrproc_t) _xdr_nis_server, (char *) cb->serv);
|
xdr_free ((xdrproc_t) _xdr_nis_server, (char *) cb->serv);
|
||||||
free (cb->serv->ep.ep_val[0].proto);
|
|
||||||
free (cb->serv->ep.ep_val[0].family);
|
|
||||||
free (cb->serv->ep.ep_val);
|
|
||||||
free (cb->serv->name);
|
|
||||||
free (cb->serv);
|
free (cb->serv);
|
||||||
free (cb);
|
free (cb);
|
||||||
syslog (LOG_ERR, "NIS+: failed to register callback dispatcher");
|
syslog (LOG_ERR, "NIS+: failed to register callback dispatcher");
|
||||||
@ -360,10 +360,6 @@ __nis_create_callback (int (*callback) (const_nis_name, const nis_object *,
|
|||||||
xprt_unregister (cb->xprt);
|
xprt_unregister (cb->xprt);
|
||||||
svc_destroy (cb->xprt);
|
svc_destroy (cb->xprt);
|
||||||
xdr_free ((xdrproc_t) _xdr_nis_server, (char *) cb->serv);
|
xdr_free ((xdrproc_t) _xdr_nis_server, (char *) cb->serv);
|
||||||
free (cb->serv->ep.ep_val[0].proto);
|
|
||||||
free (cb->serv->ep.ep_val[0].family);
|
|
||||||
free (cb->serv->ep.ep_val);
|
|
||||||
free (cb->serv->name);
|
|
||||||
free (cb->serv);
|
free (cb->serv);
|
||||||
free (cb);
|
free (cb);
|
||||||
syslog (LOG_ERR, "NIS+: failed to read local socket info");
|
syslog (LOG_ERR, "NIS+: failed to read local socket info");
|
||||||
@ -374,23 +370,6 @@ __nis_create_callback (int (*callback) (const_nis_name, const nis_object *,
|
|||||||
snprintf (addr, sizeof (addr), "%s.%d.%d", inet_ntoa (sin.sin_addr),
|
snprintf (addr, sizeof (addr), "%s.%d.%d", inet_ntoa (sin.sin_addr),
|
||||||
(port & 0xFF00) >> 8, port & 0x00FF);
|
(port & 0xFF00) >> 8, port & 0x00FF);
|
||||||
cb->serv->ep.ep_val[0].uaddr = strdup (addr);
|
cb->serv->ep.ep_val[0].uaddr = strdup (addr);
|
||||||
if (__builtin_expect (cb->serv->ep.ep_val[0].uaddr == NULL, 0))
|
|
||||||
{
|
|
||||||
free (cb->serv->ep.ep_val[0].proto);
|
|
||||||
free_family:
|
|
||||||
free (cb->serv->ep.ep_val[0].family);
|
|
||||||
free_ep_val:
|
|
||||||
free (cb->serv->ep.ep_val);
|
|
||||||
free_name:
|
|
||||||
free (cb->serv->name);
|
|
||||||
free_serv:
|
|
||||||
free (cb->serv);
|
|
||||||
free_cb:
|
|
||||||
free (cb);
|
|
||||||
free_oom:
|
|
||||||
syslog (LOG_ERR, "NIS+: out of memory allocating callback");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cb;
|
return cb;
|
||||||
}
|
}
|
||||||
@ -402,11 +381,6 @@ __nis_destroy_callback (struct nis_cb *cb)
|
|||||||
svc_destroy (cb->xprt);
|
svc_destroy (cb->xprt);
|
||||||
close (cb->sock);
|
close (cb->sock);
|
||||||
xdr_free ((xdrproc_t) _xdr_nis_server, (char *) cb->serv);
|
xdr_free ((xdrproc_t) _xdr_nis_server, (char *) cb->serv);
|
||||||
free (cb->serv->ep.ep_val[0].uaddr);
|
|
||||||
free (cb->serv->ep.ep_val[0].proto);
|
|
||||||
free (cb->serv->ep.ep_val[0].family);
|
|
||||||
free (cb->serv->ep.ep_val);
|
|
||||||
free (cb->serv->name);
|
|
||||||
free (cb->serv);
|
free (cb->serv);
|
||||||
free (cb);
|
free (cb);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user