Task #1367
closed
Change initialization of unix socket
Added by Alex Afanasyev over 10 years ago.
Updated over 10 years ago.
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
- Description updated (diff)
- Category set to Faces
- Estimated time set to 3.00 h
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.
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.
- Assignee set to Davide Pesavento
Want to double check. Is this still for version 1?
- Status changed from New to In Progress
- % Done changed from 0 to 50
- Status changed from In Progress to Closed
- % Done changed from 50 to 100
Also available in: Atom
PDF