Message ID | 1457753338-22089-1-git-send-email-dhannawatpooja1@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Don't get why we need this changes, could you explain more for it? and it seem it's not exactly correct, see below. On 03/12/2016 11:28 AM, Pooja Dhannawat wrote: > Signed-off-by: Pooja Dhannawat <dhannawatpooja1@gmail.com> > --- > net/socket.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/net/socket.c b/net/socket.c > index e32e3cb..483dcac 100644 > --- a/net/socket.c > +++ b/net/socket.c > @@ -147,10 +147,10 @@ static void net_socket_send(void *opaque) > NetSocketState *s = opaque; > int size, err; > unsigned l; > - uint8_t buf1[NET_BUFSIZE]; > + uint8_t *buf1 = g_new(uint8_t, 1); > const uint8_t *buf; > > - size = qemu_recv(s->fd, buf1, sizeof(buf1), 0); > + size = qemu_recv(s->fd, (uint8_t *)buf1, sizeof(uint8_t), 0); one byte for each reading, it looks expensive > if (size < 0) { > err = socket_error(); > if (err != EWOULDBLOCK) > @@ -170,7 +170,6 @@ static void net_socket_send(void *opaque) > s->index = 0; > s->packet_len = 0; > s->nc.link_down = true; > - memset(s->buf, 0, sizeof(s->buf)); > memset(s->nc.info_str, 0, sizeof(s->nc.info_str)); > forget to release buf1. Thanks Li ZHijian > return; > @@ -222,6 +221,7 @@ static void net_socket_send(void *opaque) > break; > } > } > + g_free(buf1); > } > > static void net_socket_send_dgram(void *opaque) >
diff --git a/net/socket.c b/net/socket.c index e32e3cb..483dcac 100644 --- a/net/socket.c +++ b/net/socket.c @@ -147,10 +147,10 @@ static void net_socket_send(void *opaque) NetSocketState *s = opaque; int size, err; unsigned l; - uint8_t buf1[NET_BUFSIZE]; + uint8_t *buf1 = g_new(uint8_t, 1); const uint8_t *buf; - size = qemu_recv(s->fd, buf1, sizeof(buf1), 0); + size = qemu_recv(s->fd, (uint8_t *)buf1, sizeof(uint8_t), 0); if (size < 0) { err = socket_error(); if (err != EWOULDBLOCK) @@ -170,7 +170,6 @@ static void net_socket_send(void *opaque) s->index = 0; s->packet_len = 0; s->nc.link_down = true; - memset(s->buf, 0, sizeof(s->buf)); memset(s->nc.info_str, 0, sizeof(s->nc.info_str)); return; @@ -222,6 +221,7 @@ static void net_socket_send(void *opaque) break; } } + g_free(buf1); } static void net_socket_send_dgram(void *opaque)
Signed-off-by: Pooja Dhannawat <dhannawatpooja1@gmail.com> --- net/socket.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)