Merge branch '6030_close_socket'

This commit is contained in:
Simon Kers 2015-02-05 17:52:02 +01:00
commit a3095f2dec
2 changed files with 2 additions and 0 deletions

View file

@ -729,6 +729,7 @@ int cwmp_init(int argc, char** argv,struct cwmp *cwmp)
}
/* Only One instance should run*/
cwmp->pid_file = open("/var/run/cwmpd.pid", O_CREAT | O_RDWR, 0666);
fcntl(cwmp->pid_file, F_SETFD, fcntl(cwmp->pid_file, F_GETFD) | FD_CLOEXEC);
int rc = flock(cwmp->pid_file, LOCK_EX | LOCK_NB);
if(rc) {
if(EWOULDBLOCK != errno)

1
ubus.c
View file

@ -128,6 +128,7 @@ cwmp_handle_command(struct ubus_context *ctx, struct ubus_object *obj,
int error;
CWMP_LOG(INFO, "triggered ubus exit");
int rc = flock(cwmp_main.pid_file, LOCK_UN | LOCK_NB);
close(cwmp_main.pid_file);
if(rc) {
char *piderr = "PID file unlock failed!";
fprintf(stderr, "%s\n", piderr);