Skip to content

Commit

Permalink
feat: check for ret <= 0 in atclient_monitor_read (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyTubongbanua authored Jun 6, 2024
1 parent 06021ea commit 051c16c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
9 changes: 0 additions & 9 deletions packages/atclient/src/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,6 @@ int atclient_connection_send(atclient_connection *ctx, const unsigned char *src,
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR, "mbedtls_ssl_read failed with exit code: %d\n", ret);
goto exit;
}
// if (ret == 0) {
// tries++;
// if (tries >= ATCLIENT_CONNECTION_MAX_READ_TRIES) {
// atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_ERROR,
// "mbedtls_ssl_read tried to read %d times and found nothing: %d\n", tries, ret);
// ret = 1;
// goto exit;
// }
// }
l = l + ret;

for (int i = l; i >= l - ret && i >= 0; i--) {
Expand Down
4 changes: 2 additions & 2 deletions packages/atclient/src/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,15 +630,15 @@ int atclient_monitor_read(atclient *monitor_conn, atclient *atclient, atclient_m
size_t off = chunksize * chunks;
for (int i = 0; i < chunksize; i++) {
ret = mbedtls_ssl_read(&(monitor_conn->atserver_connection.ssl), (unsigned char *)buffer + off + i, 1);
if (ret < 0 || buffer[off + i] == '\n') {
if (ret <= 0 || buffer[off + i] == '\n') {
buffer[off + i] = '\0';
done_reading = true;
break;
}
}
chunks = chunks + 1;
}
if (ret < 0) {
if (ret <= 0) {
(*message)->type = ATCLIENT_MONITOR_ERROR_READ;
atlogger_log(TAG, ATLOGGER_LOGGING_LEVEL_DEBUG, "Read nothing from the monitor connection: %d\n", ret);
goto exit;
Expand Down

0 comments on commit 051c16c

Please sign in to comment.