Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix memory leak in AmqpsIothubConnection #34

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -355,20 +355,30 @@ public Integer sendMessage(Message message)
}
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_017: [The function shall set the delivery tag for the sender.]
byte[] tag = String.valueOf(this. nextTag++).getBytes();
Delivery dlv = sender.delivery(tag);
Delivery dlv = sender.delivery(tag);
try
{

logger.LogInfo("Attempting to send the message using the sender link, method name is %s ", logger.getMethodName());
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_018: [The function shall attempt to send the message using the sender link.]
sender.send(msgData, 0, length);
logger.LogInfo("Attempting to send the message using the sender link, method name is %s ", logger.getMethodName());
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_018: [The function shall attempt to send the message using the sender link.]
sender.send(msgData, 0, length);

logger.LogInfo("Advancing the sender link, method name is %s ", logger.getMethodName());
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_019: [The function shall advance the sender link.]
sender.advance();

// Codes_SRS_AMQPSIOTHUBCONNECTION_15_020: [The function shall set the delivery hash to the value returned by the sender link.]
deliveryHash = dlv.hashCode();
logger.LogInfo("Delivery hash returned by the sender link %s, method name is %s ", deliveryHash, logger.getMethodName());
}
logger.LogInfo("Advancing the sender link, method name is %s ", logger.getMethodName());
// Codes_SRS_AMQPSIOTHUBCONNECTION_15_019: [The function shall advance the sender link.]
sender.advance();

// Codes_SRS_AMQPSIOTHUBCONNECTION_15_020: [The function shall set the delivery hash to the value returned by the sender link.]
deliveryHash = dlv.hashCode();
logger.LogInfo("Delivery hash returned by the sender link %s, method name is %s ", deliveryHash, logger.getMethodName());
}
catch (Exception e)
{
// If proton failed sending, release dlv object. Otherwise release it when received a disposition frame from proton.
sender.advance();
dlv.free();
deliveryHash = -1;
}
}

// Codes_SRS_AMQPSIOTHUBCONNECTION_15_021: [The function shall return the delivery hash.]
return deliveryHash;
Expand Down Expand Up @@ -595,6 +605,8 @@ public void onDelivery(Event event)
{
listener.messageSent(d.hashCode(), state);
}
// release the delivery object which created in sendMessage().
d.free();
}
}
logger.LogDebug("Exited from method %s", logger.getMethodName());
Expand Down