From: Sudipto Date: Fri, 1 Feb 2019 11:14:43 +0000 (+0530) Subject: Fix for unlimited attepmts to write to socket X-Git-Tag: accepted/tizen/unified/20190212.084048~3^2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git;a=commitdiff_plain;h=765bc0c10fd3abdec175583ecef79350c04cdf14 Fix for unlimited attepmts to write to socket Change-Id: Id90bebe5d40f1ac599d996e3e2da66217391a9eb Signed-off-by: Sudipto --- diff --git a/bt-api/bt-rfcomm-client.c b/bt-api/bt-rfcomm-client.c index 4c0b4c9..888f562 100644 --- a/bt-api/bt-rfcomm-client.c +++ b/bt-api/bt-rfcomm-client.c @@ -1287,7 +1287,7 @@ BT_EXPORT_API int bluetooth_rfcomm_disconnect(int socket_fd) #else static int __write_all(int fd, const char *buf, int len) { - int sent = 0; + int sent = 0, try = 0; BT_DBG("+"); while (len > 0) { @@ -1296,8 +1296,11 @@ static int __write_all(int fd, const char *buf, int len) written = write(fd, buf, len); BT_DBG("written: %d", written); if (written < 0) { - if (errno == EINTR || errno == EAGAIN) - continue; + if (errno == EINTR || errno == EAGAIN) { + try++; + if (try <= 49) + continue; + } return -1; } @@ -1307,6 +1310,7 @@ static int __write_all(int fd, const char *buf, int len) len -= written; buf += written; sent += written; + try = 0; } BT_DBG("-");