Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ aware and depend on particular entries in those models.
- openssl
- expat
- libev (including the event.h compatibility header, libev-libevent-dev package on Debian/Ubuntu)
- libtalloc
- libralloc
- lua 5.1
- lua-event
- xsltproc
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ AC_CHECK_LIB([lua], lua_callk, , [have_liblua=no], [-ldl -lm])
if test x$have_liblua = xno; then
AC_CHECK_LIB([lua5.1], lua_call, , AC_MSG_ERROR(Required liblua missing), [-ldl -lm])
fi
AC_CHECK_LIB(talloc, talloc_named_const, , AC_MSG_ERROR(Required libtalloc missing) )
AC_CHECK_HEADERS([talloc.h talloc/talloc.h])
AC_CHECK_LIB(ralloc, ralloc_context, , AC_MSG_ERROR(Required libralloc missing) )
AC_CHECK_HEADERS([ralloc.h])

save_LIBS=$LIBS

Expand Down
6 changes: 1 addition & 5 deletions libdmconfig/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
#include <inttypes.h>
#include <arpa/inet.h>

#ifdef HAVE_TALLOC_TALLOC_H
# include <talloc/talloc.h>
#else
# include <talloc.h>
#endif
#include <ralloc.h>

#include "errors.h"
#include "dmmsg.h"
Expand Down
10 changes: 3 additions & 7 deletions libdmconfig/dm_dmclient_rpc_skel.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
#include "libdmconfig/debug.h"
#endif

#ifdef HAVE_TALLOC_TALLOC_H
# include <talloc/talloc.h>
#else
# include <talloc.h>
#endif
#include <ralloc.h>

#include "libdmconfig/dmmsg.h"
#include "libdmconfig/dmconfig.h"
Expand Down Expand Up @@ -117,7 +113,7 @@ rpc_agent_set_boot_order_skel(void *ctx, DM2_AVPGRP *obj)
pcnt = 0;
do {
if ((pcnt % BLOCK_ALLOC) == 0)
if (!(boot_order = talloc_realloc(NULL, boot_order, char *, pcnt + BLOCK_ALLOC)))
if (!(boot_order = reralloc(NULL, boot_order, char *, pcnt + BLOCK_ALLOC)))
return RC_ERR_ALLOC;

if ((rc = dm_expect_string_type(obj, AVP_STRING, VP_TRAVELPING, &boot_order[pcnt])) != RC_OK)
Expand All @@ -128,7 +124,7 @@ rpc_agent_set_boot_order_skel(void *ctx, DM2_AVPGRP *obj)
if (rc == RC_OK)
rc = rpc_agent_set_boot_order(ctx, pcnt, (const char **)boot_order);

talloc_free(boot_order);
ralloc_free(boot_order);
return rc;
}

Expand Down
6 changes: 1 addition & 5 deletions libdmconfig/dm_dmclient_rpc_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
#include "libdmconfig/debug.h"
#endif

#ifdef HAVE_TALLOC_TALLOC_H
# include <talloc/talloc.h>
#else
# include <talloc.h>
#endif
#include <ralloc.h>

#include "libdmconfig/dmmsg.h"
#include "libdmconfig/dmconfig.h"
Expand Down
24 changes: 10 additions & 14 deletions libdmconfig/dm_dmconfig_rpc_skel.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
#include "libdmconfig/debug.h"
#endif

#ifdef HAVE_TALLOC_TALLOC_H
# include <talloc/talloc.h>
#else
# include <talloc.h>
#endif
#include <ralloc.h>

#include "libdmconfig/dmmsg.h"
#include "libdmconfig/dmconfig.h"
Expand All @@ -47,7 +43,7 @@ dm_expect_path_type(DM2_AVPGRP *grp, uint32_t exp_code, uint32_t exp_vendor_id,
if (!dm_name2sel(s, value))
r = RC_ERR_MISC;

talloc_free(s);
ralloc_free(s);
return r;
}

Expand Down Expand Up @@ -154,7 +150,7 @@ rpc_param_notify_skel(void *ctx, DM2_AVPGRP *obj, DM2_REQUEST *answer)
pcnt = 0;
do {
if ((pcnt % BLOCK_ALLOC) == 0)
if (!(path = talloc_realloc(NULL, path, dm_selector, pcnt + BLOCK_ALLOC)))
if (!(path = reralloc(NULL, path, dm_selector, pcnt + BLOCK_ALLOC)))
return RC_ERR_ALLOC;

if ((rc = dm_expect_path_type(&grp, AVP_PATH, VP_TRAVELPING, &path[pcnt])) != RC_OK)
Expand All @@ -165,7 +161,7 @@ rpc_param_notify_skel(void *ctx, DM2_AVPGRP *obj, DM2_REQUEST *answer)
if (rc == RC_OK)
rc = rpc_param_notify(ctx, notify, pcnt, path, answer);

talloc_free(path);
ralloc_free(path);
return rc;
}

Expand Down Expand Up @@ -233,7 +229,7 @@ rpc_db_set_skel(void *ctx, DM2_AVPGRP *obj, DM2_REQUEST *answer)
DM2_AVPGRP grp;

if ((pvcnt % BLOCK_ALLOC) == 0)
if (!(values = talloc_realloc(NULL, values, struct rpc_db_set_path_value, pvcnt + BLOCK_ALLOC)))
if (!(values = reralloc(NULL, values, struct rpc_db_set_path_value, pvcnt + BLOCK_ALLOC)))
return RC_ERR_ALLOC;

if ((rc = dm_expect_object(obj, &grp)) != RC_OK
Expand All @@ -247,7 +243,7 @@ rpc_db_set_skel(void *ctx, DM2_AVPGRP *obj, DM2_REQUEST *answer)

rc = rpc_db_set(ctx, pvcnt, values, answer);

talloc_free(values);
ralloc_free(values);
return rc;
}

Expand All @@ -261,7 +257,7 @@ rpc_db_get_skel(void *ctx, DM2_AVPGRP *obj, DM2_REQUEST *answer)
pcnt = 0;
do {
if ((pcnt % BLOCK_ALLOC) == 0)
if (!(values = talloc_realloc(NULL, values, dm_selector, pcnt + BLOCK_ALLOC)))
if (!(values = reralloc(NULL, values, dm_selector, pcnt + BLOCK_ALLOC)))
return RC_ERR_ALLOC;

if ((rc = dm_expect_path_type(obj, AVP_PATH, VP_TRAVELPING, values + pcnt)) != RC_OK)
Expand All @@ -273,7 +269,7 @@ rpc_db_get_skel(void *ctx, DM2_AVPGRP *obj, DM2_REQUEST *answer)
if (rc == RC_OK)
rc = rpc_db_get(ctx, pcnt, values, answer);

talloc_free(values);
ralloc_free(values);
return rc;
}

Expand Down Expand Up @@ -455,7 +451,7 @@ rpc_set_boot_order_skel(void *ctx, DM2_AVPGRP *obj)
pcnt = 0;
do {
if ((pcnt % BLOCK_ALLOC) == 0)
if (!(boot_order = talloc_realloc(NULL, boot_order, char *, pcnt + BLOCK_ALLOC)))
if (!(boot_order = reralloc(NULL, boot_order, char *, pcnt + BLOCK_ALLOC)))
return RC_ERR_ALLOC;

if ((rc = dm_expect_string_type(obj, AVP_STRING, VP_TRAVELPING, &boot_order[pcnt])) != RC_OK)
Expand All @@ -466,7 +462,7 @@ rpc_set_boot_order_skel(void *ctx, DM2_AVPGRP *obj)
if (rc == RC_OK)
rc = rpc_set_boot_order(ctx, pcnt, (const char **)boot_order);

talloc_free(boot_order);
ralloc_free(boot_order);
return rc;
}

Expand Down
6 changes: 1 addition & 5 deletions libdmconfig/dm_dmconfig_rpc_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
#include "libdmconfig/debug.h"
#endif

#ifdef HAVE_TALLOC_TALLOC_H
# include <talloc/talloc.h>
#else
# include <talloc.h>
#endif
#include <ralloc.h>

#include "libdmconfig/dmmsg.h"
#include "libdmconfig/dmcontext.h"
Expand Down
12 changes: 4 additions & 8 deletions libdmconfig/dmconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@
#include "debug.h"
#endif

#ifdef HAVE_TALLOC_TALLOC_H
# include <talloc/talloc.h>
#else
# include <talloc.h>
#endif
#include <ralloc.h>

#include "mand/dm_token.h"
#include "mand/dm_strings.h"
Expand Down Expand Up @@ -248,7 +244,7 @@ uint32_t dm_expect_string_type(DM2_AVPGRP *grp, uint32_t exp_code, uint32_t exp_
if ((r = dm_expect_raw(grp, exp_code, exp_vendor_id, &data, &size)) != RC_OK)
return r;

if (!(*value = talloc_strndup(grp->ctx, data, size)))
if (!(*value = ralloc_strndup(grp->ctx, data, size)))
return RC_ERR_ALLOC;

return RC_OK;
Expand Down Expand Up @@ -418,11 +414,11 @@ DM2_REQUEST *dm_new_request(void *ctx, uint32_t code, uint8_t flags, uint32_t ho
{
DM2_REQUEST *req;

if (!(req = talloc_zero(ctx, DM2_REQUEST)))
if (!(req = rzalloc(ctx, DM2_REQUEST)))
return NULL;

if (dm_new_packet(ctx, req, code, flags, APP_ID, hopid, endid) != RC_OK) {
talloc_free(req);
ralloc_free(req);
return NULL;
}

Expand Down
6 changes: 1 addition & 5 deletions libdmconfig/dmconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@
#include <sys/queue.h>
#include <ev.h>

#ifdef HAVE_TALLOC_TALLOC_H
# include <talloc/talloc.h>
#else
# include <talloc.h>
#endif
#include <ralloc.h>

#include "dmmsg.h"
#include "libdmconfig/codes.h"
Expand Down
35 changes: 16 additions & 19 deletions libdmconfig/dmcontext.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@

#include "debug.h"

#ifdef HAVE_TALLOC_TALLOC_H
# include <talloc/talloc.h>
#else
# include <talloc.h>
#endif
#include <ralloc.h>

#include "dmmsg.h"
#include "codes.h"
Expand Down Expand Up @@ -110,7 +106,7 @@ connection_error(DMCONTEXT *socket, DMCONFIG_EVENT event)
DMCONTEXT*
dm_context_new()
{
return talloc(NULL, DMCONTEXT);
return ralloc(NULL, DMCONTEXT);
}

/** aquire a reference to a socket context
Expand Down Expand Up @@ -140,7 +136,7 @@ dm_context_release(DMCONTEXT *dmCtx)
r = dmCtx->_ref;

if (dmCtx->_ref == 0)
talloc_free(dmCtx);
ralloc_free(dmCtx);

return r;
}
Expand Down Expand Up @@ -190,9 +186,10 @@ uint32_t dm_enqueue(DMCONTEXT *socket, DM2_REQUEST *req, int flags, DMRESULT_CB
req->packet->end2end_id = htonl(endid);
}

if (!(rqi = talloc_zero(socket, DM2_REQUEST_INFO)))
if (!(rqi = rzalloc(socket, DM2_REQUEST_INFO)))
return RC_ERR_ALLOC;
rqi->packet = talloc_steal(rqi, req->packet);
ralloc_steal(rqi, req->packet);
rqi->packet = req->packet;
rqi->flags = flags;
rqi->reply_cb = cb;
rqi->userdata = data;
Expand Down Expand Up @@ -305,7 +302,7 @@ acceptEvent(EV_P_UNUSED_ ev_io *w, int revents)
return;
}

if (!(sock = talloc_zero(NULL, DMCONTEXT)))
if (!(sock = rzalloc(NULL, DMCONTEXT)))
return;

trace(":[%p] new socket [%p]", acceptSock, sock);
Expand Down Expand Up @@ -370,7 +367,7 @@ readEvent(EV_P_ ev_io *w, int revents __attribute__((unused)))
if (len != sizeof(buf))
return;

ctx->pos = ctx->packet = talloc_size(socket, dm_packet_length(&buf));
ctx->pos = ctx->packet = ralloc_size(socket, dm_packet_length(&buf));
ctx->left = dm_packet_length(&buf);
trace(":[%p] recv ctx->left: %zd", socket, ctx->left);
}
Expand Down Expand Up @@ -424,7 +421,7 @@ readEvent(EV_P_ ev_io *w, int revents __attribute__((unused)))
else
process_reply(socket, ctx->packet);

talloc_free(ctx->packet);
ralloc_free(ctx->packet);
ctx->packet = ctx->pos = NULL;
ctx->left = 0;

Expand Down Expand Up @@ -467,7 +464,7 @@ process_reply(DMCONTEXT *socket, DM_PACKET *pkt)
return;

TAILQ_REMOVE(&socket->head, req, entries);
talloc_steal(pkt, req);
ralloc_steal(pkt, req);

CALLBACK(req->reply_cb, socket, DMCONFIG_ANSWER_READY, &grp, req->userdata);
}
Expand Down Expand Up @@ -502,12 +499,12 @@ writeEvent(EV_P_ ev_io *w, int revents __attribute__((unused)))

ctx->pos = ctx->packet = req->packet;
ctx->left = dm_packet_length(ctx->packet);
talloc_steal(socket, req->packet);
ralloc_steal(socket, req->packet);

if (req->flags & (ONE_WAY | REPLY)) {
/* drop the packet from the request queue */
TAILQ_REMOVE(&socket->head, req, entries);
talloc_free(req);
ralloc_free(req);
} else
req->status = REQUEST_SHALL_READ;
}
Expand Down Expand Up @@ -547,7 +544,7 @@ writeEvent(EV_P_ ev_io *w, int revents __attribute__((unused)))
trace(":[%p] loop exit: %zd bytes,ctx->left: %zd ", socket, len, ctx->left);

if (ctx->left == 0) {
talloc_free(ctx->packet);
ralloc_free(ctx->packet);
ctx->packet = NULL;
}

Expand All @@ -570,13 +567,13 @@ dm_free_requests(DMCONTEXT *sock, DMCONFIG_EVENT event)
r = TAILQ_FIRST(&sock->head);
TAILQ_REMOVE(&sock->head, r, entries);
CALLBACK(r->reply_cb, sock, event, NULL, r->userdata);
talloc_free(r);
ralloc_free(r);
}

talloc_free(sock->writeCtx.packet);
ralloc_free(sock->writeCtx.packet);
sock->writeCtx.packet = NULL;

talloc_free(sock->readCtx.packet);
ralloc_free(sock->readCtx.packet);
sock->readCtx.packet = NULL;
}

Expand Down
Loading