Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

Commit

Permalink
wrap dpdk cmdline_printf function with our own so we can use send(MSG…
Browse files Browse the repository at this point in the history
…_NOSIGNAL)
  • Loading branch information
klnikita committed Oct 20, 2015
1 parent ad6cda3 commit 8063c9b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ LDFLAGS += -L$(BASE_OUTPUT)/lib/libneighbour/$(RTE_TARGET)/lib -L$(BASE_OUTPUT)/
ifeq ($(BUILD_TARGET),qemu)
LDFLAGS += --wrap=virtio_recv_mergeable_pkts
endif
LDFLAGS += --wrap=cmdline_printf

# workaround for a gcc bug with noreturn attribute
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12603
Expand Down
33 changes: 33 additions & 0 deletions app/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,39 @@

#define CMDLINE_POLL_TIMEOUT 500

void
__wrap_cmdline_printf(const struct cmdline *cl, const char *fmt, ...);

void
__wrap_cmdline_printf(const struct cmdline *cl, const char *fmt, ...)
{
va_list ap;

if (!cl || !fmt)
return;

int ret;
char *buf;

if (cl->s_out < 0)
return;

buf = malloc(BUFSIZ);
if (buf == NULL)
return;
va_start(ap, fmt);
ret = vsnprintf(buf, BUFSIZ, fmt, ap);
va_end(ap);
if (ret < 0) {
free(buf);
return;
}
if (ret >= BUFSIZ)
ret = BUFSIZ - 1;
send(cl->s_out, buf, ret, MSG_NOSIGNAL);
free(buf);
}

static pthread_t cmdline_tid[NB_SOCKETS];

struct client_data_t cmdline_clients[NB_SOCKETS][CMDLINE_MAX_CLIENTS];
Expand Down

0 comments on commit 8063c9b

Please sign in to comment.