socket: dont't free msgfds if error equals EAGAIN
PATCH 1/1 socket: dont't free msgfds if error equals EAGAIN
chardev/char-socket.c +2 -2
@@ -134,8 +134,8 @@ static int tcp_chr_write(Chardev *chr, const uint8_t *buf, int len) s->write_msgfds, s->write_msgfds_num); -/* free the written msgfds, no matter what */ -if (s->write_msgfds_num) { +/* free the written msgfds in any cases other than errno==EAGAIN */ +if (EAGAIN != errno && s->write_msgfds_num) {g_free (s->write_msgfds); s->write_msgfds =0 ; s->write_msgfds_num =0 ;
Signature · 1 line
2.12.2.windows.2
Hi
Quoted 8 lines · linzhecheng
Signed-off-by linzhecheng <[email protected]>chardev/char-socket.c +0
-0@@ -134,8 +134,8 @@ static int tcp_chr_write(Chardev *chr, const uint8_t *buf, int len) s->write_msgfds,
chardev/char-socket.c static int tcp_chr_write(Chardev *chr, const uint8_t *buf, int len)
Quoted 10 lines
chardev/char-socket.c +2
-3s->write_msgfds_num); -/* free the written msgfds, no matter what */ -if (s->write_msgfds_num) { +/* free the written msgfds in any cases other than errno==EAGAIN */ +if (EAGAIN != errno && s->write_msgfds_num) {g_free (s->write_msgfds); s->write_msgfds =0 ; s->write_msgfds_num =0 ; --
It is already fix since v2.12:
commit c863fdec6aff6b5a4ca8fff1537b80d9f8b97726
Author: Daniel P. Berrangé <[email protected]> Date: Thu Feb 22 12:13:51 2018 +0000
chardev: fix handling of EAGAIN for TCP chardev
Quoted 4 lines
2.12.2.windows.2
Signature · 1 line
Marc-André Lureau
Quoted 7 lines · linzhecheng
Signed-off-by linzhecheng <[email protected]>chardev/char-socket.c +0
-0
chardev/char-socket.c static int tcp_chr_write(Chardev *chr, const uint8_t *buf, int len) · line 138
Quoted 7 lines
chardev/char-socket.c +2
-2@@ -134,8 +134,8 @@ static int tcp_chr_write(Chardev *chr, const uint8_t *buf, int len) s->write_msgfds, s->write_msgfds_num); -/* free the written msgfds, no matter what */ -if (s->write_msgfds_num) { +/* free the written msgfds in any cases other than errno==EAGAIN */ +if (EAGAIN != errno && s->write_msgfds_num) {
This makes sense to me.
Meanwhile this reminds me that we didn't release the fds in tcp_chr_disconnect(). I'm thinking whether we should do that no matter what. E.g., what if we set_msgfds() then another operation instead of write() failed?
Then here we can only release the msgfds when write succeeded...
if (ret >= 0 && s->write_msgfds_num) {...as long as we'll also cleanup the msgfds in tcp_chr_disconnect() always.
I'll see how Marc-Andre and Paolo see this though.
Thanks,
Quoted 8 lines
chardev/char-socket.c +0
-0g_free (s->write_msgfds); s->write_msgfds =0 ; s->write_msgfds_num =0 ;Signature · 1 line
2.12.2.windows.2
Signature · 1 line
Peter Xu
Quoted 7 lines · linzhecheng
Signed-off-by linzhecheng <[email protected]>chardev/char-socket.c +0
-0
chardev/char-socket.c static int tcp_chr_write(Chardev *chr, const uint8_t *buf, int len) · line 141
Quoted 10 lines
chardev/char-socket.c +2
-2@@ -134,8 +134,8 @@ static int tcp_chr_write(Chardev *chr, const uint8_t *buf, int len) s->write_msgfds, s->write_msgfds_num); -/* free the written msgfds, no matter what */ -if (s->write_msgfds_num) { +/* free the written msgfds in any cases other than errno==EAGAIN */ +if (EAGAIN != errno && s->write_msgfds_num) {g_free (s->write_msgfds); s->write_msgfds =0 ; s->write_msgfds_num =0 ;
Thanks, queued with an updated commit message
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|