From ee8b314dbc590b2435d07600baa8327c11e67615 Mon Sep 17 00:00:00 2001 From: Ethan Yonker Date: Mon, 29 Dec 2014 08:39:19 -0600 Subject: Improve MTPServer logging of read errors Unless MTP debug logging is enabled, you will miss the error and will not know that something went wrong in the log. Change-Id: I51f4758b415eb38e808ec8b1c9788b505bf88c65 --- mtp/MtpServer.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mtp/MtpServer.cpp b/mtp/MtpServer.cpp index 142b821b8..2c6d37648 100755 --- a/mtp/MtpServer.cpp +++ b/mtp/MtpServer.cpp @@ -192,11 +192,12 @@ void MtpServer::run() { MTPD("About to read device...\n"); int ret = mRequest.read(fd); if (ret < 0) { - MTPD("request read returned %d, errno: %d", ret, errno); if (errno == ECANCELED) { // return to top of loop and wait for next command + MTPD("request read returned %d ECANCELED, starting over\n", ret); continue; } + MTPE("request read returned %d, errno: %d, exiting MtpServer::run loop\n", ret, errno); break; } MtpOperationCode operation = mRequest.getOperationCode(); @@ -213,11 +214,12 @@ void MtpServer::run() { if (dataIn) { int ret = mData.read(fd); if (ret < 0) { - MTPD("data read returned %d, errno: %d", ret, errno); if (errno == ECANCELED) { // return to top of loop and wait for next command + MTPD("data read returned %d ECANCELED, starting over\n", ret); continue; } + MTPD("data read returned %d, errno: %d, exiting MtpServer::run loop\n", ret, errno); break; } MTPD("received data:"); @@ -234,11 +236,12 @@ void MtpServer::run() { mData.dump(); ret = mData.write(fd); if (ret < 0) { - MTPD("request write returned %d, errno: %d", ret, errno); if (errno == ECANCELED) { // return to top of loop and wait for next command + MTPD("data write returned %d ECANCELED, starting over\n", ret); continue; } + MTPE("data write returned %d, errno: %d, exiting MtpServer::run loop\n", ret, errno); break; } } @@ -249,11 +252,12 @@ void MtpServer::run() { MTPD("ret: %d\n", ret); mResponse.dump(); if (ret < 0) { - MTPD("request write returned %d, errno: %d", ret, errno); if (errno == ECANCELED) { // return to top of loop and wait for next command + MTPD("response write returned %d ECANCELED, starting over\n", ret); continue; } + MTPE("response write returned %d, errno: %d, exiting MtpServer::run loop\n", ret, errno); break; } } else { -- cgit v1.2.3