Skip to content

Commit

Permalink
notifier: don't initialize socket strucures twice
Browse files Browse the repository at this point in the history
struct sockaddr_un notify_server is initialized via addr_init()
at notify_init()'s start and on initialization in notifier_thread().
As once is sufficient, remove the initialization in notifier_thread().

Signed-off-by: Christian Storm <[email protected]>
Reviewed-by: Stefano Babic <[email protected]>
  • Loading branch information
stormc authored and sbabic committed Mar 20, 2018
1 parent 3e9abee commit 33c8689
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions core/notifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,11 @@ static void addr_init(struct sockaddr_un *addr, const char *path)
{
memset(addr, 0, sizeof(struct sockaddr_un));
addr->sun_family = AF_UNIX;
/*
* Use Linux-specific abstract sockets for this internal interface
*/
strcpy(&addr->sun_path[1], path);
addr->sun_path[0] = 0;
addr->sun_path[0] = '\0';
}

/*
Expand All @@ -232,14 +235,6 @@ static void *notifier_thread (void __attribute__ ((__unused__)) *data)
fprintf(stderr, "Error creating notifier daemon, exiting.");
exit(2);
}
memset(&notify_server, 0, sizeof(notify_server));
notify_server.sun_family = AF_UNIX;
strcpy(notify_server.sun_path, "#NotifyServer");

/*
* Use Abstract Socket Address because this is an internal interface
*/
notify_server.sun_path[0] = 0;

if (bind(serverfd, (const struct sockaddr *) &notify_server,
sizeof(struct sockaddr_un)) < 0) {
Expand Down

0 comments on commit 33c8689

Please sign in to comment.