|
From: | David Marchand |
Subject: | Re: [Qemu-devel] [PATCH v5 1/3] contrib: add ivshmem client and server |
Date: | Fri, 05 Sep 2014 14:07:54 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.7.0 |
Hello Michael, On 09/04/2014 05:56 PM, Michael S. Tsirkin wrote:
+ /* create the unix listening socket */ + sock_fd = socket(AF_UNIX, SOCK_STREAM, 0); + if (sock_fd < 0) { + debug_log(server, "cannot create socket: %s\n", strerror(errno)); + goto err_close_shm; + } + + sun.sun_family = AF_UNIX; + snprintf(sun.sun_path, sizeof(sun.sun_path), "%s", server->unix_sock_path); + unlink(sun.sun_path);why unlink it?
Yes, this is wrong, because this means that when starting multiple servers on the same socket, the last server is the one who wins ... while I think it should be the opposite (first server wins, as it may have some connected clients). I have been scratching my head about this: when should I unlink ? My current fix unlinks from ivshmem_server_close() (which should be the right place). I need to call this when exiting, but I can only do this when the serverexits gracefully (when an error occurs on the server socket or when receiving a SIGTERM).
If something unexpected happens (like a bug/crash or a SIGKILL), the socket won't be unlinked and the next server process will refuse to start. Is this something acceptable ? Do you have a better idea ? Thanks. -- David Marchand
[Prev in Thread] | Current Thread | [Next in Thread] |