[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3 10/31] libxl_qmp: Move buffers to the stack of qmp_next.
That buffer is only used locally, and never reuse accross different call of qmp_next. So remove it form the handler. Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> --- tools/libxl/libxl_qmp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c index 251840a155..4da84dcf16 100644 --- a/tools/libxl/libxl_qmp.c +++ b/tools/libxl/libxl_qmp.c @@ -111,7 +111,6 @@ struct libxl__qmp_handler { /* wait_for_id will be used by the synchronous send function */ int wait_for_id; - char buffer[QMP_RECEIVE_BUFFER_SIZE + 1]; libxl__yajl_ctx *yajl_ctx; libxl_ctx *ctx; @@ -501,6 +500,7 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp) char *incomplete = NULL; size_t incomplete_size = 0; int rc = 0; + char buffer[QMP_RECEIVE_BUFFER_SIZE + 1]; do { fd_set rfds; @@ -524,7 +524,7 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp) return -1; } - rd = read(qmp->qmp_fd, qmp->buffer, QMP_RECEIVE_BUFFER_SIZE); + rd = read(qmp->qmp_fd, buffer, QMP_RECEIVE_BUFFER_SIZE); if (rd == 0) { LOGD(ERROR, qmp->domid, "Unexpected end of socket"); return -1; @@ -532,20 +532,20 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp) LOGED(ERROR, qmp->domid, "Socket read error"); return rd; } - qmp->buffer[rd] = '\0'; + buffer[rd] = '\0'; - DEBUG_REPORT_RECEIVED(qmp->domid, qmp->buffer, (int)rd); + DEBUG_REPORT_RECEIVED(qmp->domid, buffer, (int)rd); if (incomplete) { size_t current_pos = s - incomplete; incomplete = libxl__realloc(gc, incomplete, incomplete_size + rd + 1); - strncat(incomplete + incomplete_size, qmp->buffer, rd); + strncat(incomplete + incomplete_size, buffer, rd); s = incomplete + current_pos; incomplete_size += rd; s_end = incomplete + incomplete_size; } else { - incomplete = libxl__strndup(gc, qmp->buffer, rd); + incomplete = libxl__strndup(gc, buffer, rd); incomplete_size = rd; s = incomplete; s_end = s + rd; -- Anthony PERARD _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |