Task #1367
closedChange initialization of unix socket
100%
Description
Currently, NFD checks if the unix socket file exists and if so simply deletes the file. This causes problems when NFD is run twice (i.e., the second attempt will fail because it will not be able to bind to tcp/udp socket, but will disable any future communication via unix socket).
This task is to change this behavior. Instead of just deleting existing file, the initialization procedure should:
- if UNIX socket doesn’t exist, goto step 4
- connect to the UNIX socket, if connection succeeds (indicating another process is listening on the same socket), raise an error and abort these steps
- delete the UNIX socket
- start listening
Updated by Junxiao Shi almost 11 years ago
- Description updated (diff)
- Category set to Faces
- Estimated time set to 3.00 h
Updated by Davide Pesavento almost 11 years ago
The described procedure is still not race-free. There's a race condition if two nfd processes start up more or less at the same time and no other process is listening on the socket. Usually, an advisory lock such as flock(2) is used on a PID file. Given that you don't want to create a PID file, I believe the same mechanism can be applied to the socket file.
Updated by Junxiao Shi almost 11 years ago
This solution is design to solve #1360 where user starts the second instance by mistake. It works as long as time between checking and listening is less than human think time.
Updated by Alex Afanasyev over 10 years ago
Want to double check. Is this still for version 1?
Updated by Davide Pesavento over 10 years ago
- Status changed from New to In Progress
- % Done changed from 0 to 50
Updated by Junxiao Shi over 10 years ago
- Status changed from In Progress to Closed
- % Done changed from 50 to 100