qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ashi <ashijeetacharya@gmail.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: jasowang@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Modify net/socket.c to use socket_* functions from include/qemu/sockets.h
Date: Tue, 31 May 2016 15:27:42 +0530	[thread overview]
Message-ID: <574D6016.8020706@gmail.com> (raw)
In-Reply-To: <20160516164123.GC15256@stefanha-x1.localdomain>



On Monday 16 May 2016 10:11 PM, Stefan Hajnoczi wrote:
> On Thu, May 12, 2016 at 10:33:05PM +0530, Ashijeet Acharya wrote:
>> Changed the listen(),connect(),parse_host_port() in net/socket.c with the socket_*()functions in include/qemu/sockets.h.
>
> What is the rationale for this change?  Please explain why this is
> necessary or a good idea.

This patch consists of basic api conversion since i guess everything 
will be using QAPI based socket_* functions in the future and the same 
task was listed on this http://wiki.qemu.org/BiteSizedTasks page too.

>
> Please summarize the address syntax changes in this patch and update the
> QEMU man page.

Syntax changes:

1. connect() -> socket_connect()
2. listen() -> socket_listen()
3. parse_host_port() -> socket_parse()
4, delete bind as it is automatically done inside socket_listen.
5. use SocketAddress as data-type of socket variable saddr.

>
>>
>> Signed-off-by: Ashijeet Acharya <ashijeetacharya@gmail.com>
>> ---
>>   net/socket.c | 38 +++++++++++++++++++-------------------
>>   1 file changed, 19 insertions(+), 19 deletions(-)
>>
>> diff --git a/net/socket.c b/net/socket.c
>> index 9fa2cd8..b6e2f3e 100644
>> --- a/net/socket.c
>> +++ b/net/socket.c
>> @@ -522,10 +522,12 @@ static int net_socket_listen_init(NetClientState *peer,
>>   {
>>       NetClientState *nc;
>>       NetSocketState *s;
>> -    struct sockaddr_in saddr;
>> +    SocketAddress *saddr;
>>       int fd, ret;
>> +    Error *local_error = NULL;
>> +    saddr = g_new0(SocketAddress, 1);
>>
>> -    if (parse_host_port(&saddr, host_str) < 0)
>> +    if (socket_parse(host_str, &local_error) < 0)
>>           return -1;
>
> saddr is leaked.  Please check all return code paths and avoid memory
> leaks.
>
> I'm not sure if it makes sense to allocate a new SocketAddress object
> since it is assigned a different object further down in the patch:
>
> saddr = socket_local_address(fd, &local_error);
>
I have looked into it and hopefully solved the memory leakage problem as 
you can see in the new patch.


Thanks
Ashijeet Acharya

  parent reply	other threads:[~2016-05-31  9:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-12 17:03 [Qemu-devel] [PATCH] Modify net/socket.c to use socket_* functions from include/qemu/sockets.h Ashijeet Acharya
2016-05-16 16:41 ` Stefan Hajnoczi
2016-05-31  9:27   ` Ashijeet Acharya
2016-05-31 15:01     ` Paolo Bonzini
2016-06-05 18:06       ` Ashijeet Acharya
2016-06-06  8:07         ` Paolo Bonzini
2016-06-16 10:20     ` [Qemu-devel] [PATCH] Change net/socket.c to use socket_*() functions Ashijeet Acharya
2016-06-17 12:38       ` Paolo Bonzini
2016-06-18  7:54       ` [Qemu-devel] [PATCH v2] " Ashijeet Acharya
2016-06-20 14:55         ` Paolo Bonzini
2016-06-20 15:09           ` Peter Maydell
2016-06-21  1:49             ` Jason Wang
2016-06-21  7:06               ` Ashijeet Acharya
2016-06-23  9:27         ` Daniel P. Berrange
2016-05-31  9:57   ` Ashi [this message]
2016-06-09 12:19     ` [Qemu-devel] [PATCH] Modify net/socket.c to use socket_* functions from include/qemu/sockets.h Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=574D6016.8020706@gmail.com \
    --to=ashijeetacharya@gmail.com \
    --cc=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).