Added code to remove stale unix domain socket files on startup and

shutdown.
This commit is contained in:
gardners 2012-03-19 09:43:11 +10:30
parent 9a957dbda7
commit f43143bd0f
2 changed files with 5 additions and 1 deletions

2
dna.c
View File

@ -305,6 +305,8 @@ void servalShutdownCleanly()
unlink(filename);
snprintf(filename,1024,"%s/serval.pid",instancepath);
unlink(filename);
snprintf(filename,1024,"%s/mdp.socket",instancepath);
unlink(filename);
exit(0);
}

View File

@ -60,8 +60,10 @@ int overlay_mdp_setup_sockets()
#endif
if (mdp_named_socket==-1) {
char *instancepath=serval_instancepath();
if (strlen(instancepath)>85) return WHY("Instance path too long to allow construction of named unix domain socket.");
snprintf(&name.sun_path[0],100,"%s/mdp.socket",instancepath);
len = 0+strlen(&name.sun_path[0]) + sizeof(name.sun_family);
unlink(&name.sun_path[0]);
len = 0+strlen(&name.sun_path[0]) + sizeof(name.sun_family)+1;
mdp_named_socket = socket(AF_UNIX, SOCK_DGRAM, 0);
if (mdp_named_socket>-1) {
int dud=0;