From: Gowtham Anandha Babu Date: Mon, 29 May 2017 13:41:03 +0000 (+0530) Subject: [OTP] Fix Object Read logic X-Git-Tag: submit/tizen/20170613.061617~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fe6f5af851ff5e49ab0e70262abc07ce737e5327;p=platform%2Fcore%2Fapi%2Fbluetooth.git [OTP] Fix Object Read logic Change-Id: Iac4e6ca7593e6127ba100fbf3ae49a80f1ac90f2 Signed-off-by: Gowtham Anandha Babu --- diff --git a/src/bluetooth-otp.c b/src/bluetooth-otp.c index 3224664..3ed8125 100644 --- a/src/bluetooth-otp.c +++ b/src/bluetooth-otp.c @@ -1298,7 +1298,7 @@ static bool __bt_otc_connection_timeout_cb(gpointer user_data) _bt_convert_address_to_hex(&addr_hex, address); bluetooth_otp_disconnect_otc(&addr_hex); - return FALSE; + return TRUE; } static gboolean __client_data_received_cb(GIOChannel *chan, GIOCondition cond, @@ -1382,16 +1382,15 @@ static gboolean __client_data_received_cb(GIOChannel *chan, GIOCondition cond, oacp_read_op->fp = fp; oacp_read_op->size = object_info->curr_size; oacp_read_op->file_path = g_strdup(file_path); - } else { - oacp_read_op->offset += (oacp_read_op->length - oacp_read_op->offset); } - fseek(oacp_read_op->fp, oacp_read_op->offset, SEEK_SET); - written = fwrite(buffer, 1, len, oacp_read_op->fp); - oacp_read_op->length += len; - BT_DBG("written [%d], offset [%lu], length [%lu], size [%lu]", - written, oacp_read_op->offset, - oacp_read_op->length, oacp_read_op->size); + if (oacp_read_op->length <= oacp_read_op->size) { + written = fwrite(buffer, 1, len, oacp_read_op->fp); + oacp_read_op->length += written; + BT_DBG("written [%d], length_sofar [%lu], received_buff_len [%d], size [%lu]", + written, oacp_read_op->length, len, oacp_read_op->size); + } + if (timeout_id > 0) { g_source_remove(timeout_id); timeout_id = g_timeout_add(BT_OTC_CONNECTION_MAX_TIMEOUT,