usb: native_posix: Use non-blocking socket
Use non-blocking socket for native_posix to allow other processes to run. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
071a72dccc
commit
03b7d9f59d
1 changed files with 8 additions and 1 deletions
|
@ -313,7 +313,7 @@ void usbip_start(void)
|
||||||
posix_exit(EXIT_FAILURE);
|
posix_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
listenfd = socket(PF_INET, SOCK_STREAM, 0);
|
listenfd = socket(PF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
|
||||||
if (listenfd < 0) {
|
if (listenfd < 0) {
|
||||||
SYS_LOG_ERR("socket() failed: %s", strerror(errno));
|
SYS_LOG_ERR("socket() failed: %s", strerror(errno));
|
||||||
posix_exit(EXIT_FAILURE);
|
posix_exit(EXIT_FAILURE);
|
||||||
|
@ -346,6 +346,13 @@ void usbip_start(void)
|
||||||
connfd = accept(listenfd, (struct sockaddr *)&client_addr,
|
connfd = accept(listenfd, (struct sockaddr *)&client_addr,
|
||||||
&client_addr_len);
|
&client_addr_len);
|
||||||
if (connfd < 0) {
|
if (connfd < 0) {
|
||||||
|
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||||
|
/* Non-blocking accept */
|
||||||
|
k_sleep(100);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
SYS_LOG_ERR("accept() failed: %s", strerror(errno));
|
SYS_LOG_ERR("accept() failed: %s", strerror(errno));
|
||||||
posix_exit(EXIT_FAILURE);
|
posix_exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue