summaryrefslogtreecommitdiff
path: root/lib/avtp_pipeline/platform/Linux/endpoint/openavb_endpoint_server_osal.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/avtp_pipeline/platform/Linux/endpoint/openavb_endpoint_server_osal.c')
-rw-r--r--lib/avtp_pipeline/platform/Linux/endpoint/openavb_endpoint_server_osal.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/avtp_pipeline/platform/Linux/endpoint/openavb_endpoint_server_osal.c b/lib/avtp_pipeline/platform/Linux/endpoint/openavb_endpoint_server_osal.c
index c921d358..3454270f 100644
--- a/lib/avtp_pipeline/platform/Linux/endpoint/openavb_endpoint_server_osal.c
+++ b/lib/avtp_pipeline/platform/Linux/endpoint/openavb_endpoint_server_osal.c
@@ -1,5 +1,6 @@
/*************************************************************************************************************
Copyright (c) 2012-2015, Symphony Teleca Corporation, a Harman International Industries, Incorporated company
+Copyright (c) 2016-2017, Harman International Industries, Incorporated
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -117,6 +118,11 @@ bool openavbEndpointServerOpen(void)
serverAddr.sun_family = AF_UNIX;
snprintf(serverAddr.sun_path, UNIX_PATH_MAX, AVB_ENDPOINT_UNIX_PATH);
+ // try remove old socket
+ if (unlink(serverAddr.sun_path) < 0 && errno != ENOENT) {
+ AVB_LOGF_ERROR("Failed to remove %s: %s", serverAddr.sun_path, strerror(errno));
+ }
+
int rslt = bind(lsock, (struct sockaddr*)&serverAddr, sizeof(struct sockaddr_un));
if (rslt != 0) {
AVB_LOGF_ERROR("Failed to create %s: %s", serverAddr.sun_path, strerror(errno));
@@ -140,7 +146,7 @@ bool openavbEndpointServerOpen(void)
error:
if (lsock >= 0) {
close(lsock);
- lsock = -1;
+ lsock = SOCK_INVALID;
}
AVB_TRACE_EXIT(AVB_TRACE_ENDPOINT);
return FALSE;
@@ -239,10 +245,12 @@ void openavbEndpointServerClose(void)
for (i = 0; i < POLL_FD_COUNT; i++) {
if (fds[i].fd != SOCK_INVALID) {
close(fds[i].fd);
+ fds[i].fd = SOCK_INVALID;
}
}
if (lsock != SOCK_INVALID) {
close(lsock);
+ lsock = SOCK_INVALID;
}
if (unlink(serverAddr.sun_path) != 0) {